* 05/28 Update: An underline has been added to a certain sentence *
This is a partial judge problem.
Built-in Sorting function and C++ containers are forbidden. NO credit if you use any of them.
There are many people buying food at 水木 (shuǐ mù, Water Wood) Food Court every day. The seats are limited, so many students can’t find places to sit during the lunch breaks. If you are a NTHU student, you probably had experienced that before. To know how many seats we need, you must analyze the customer traffic first.
Since the limited seats will influence the number of incoming customers, you might need to create a virtual environment without seating condition. Assume you can cast a spell to remove all furniture and enlarge the ground so that everyone has a space. (They said that programming is like magic in fantasy, so ¯\_(ツ)_/¯)
For simplicity, you only need to look at the traffic of one day in each testcase. Also, everyone eats their food in the food court (they won’t ask for takeout.) In addition, people go to the food court in groups and the people in the same group buy their food from the same store.
In each testcase, there will be n groups and their information will be given in the input one by one. For any group i, the information will be specified in a line consists of 3 integers and 1 string without whitespaces, including:
You need to develop a program to organize the data and it should be able to provide the following information that can be queried by a user:
Note:
The times people arrive and leave at will be represented by non-negative integers. When group i leaves at time Li, group i is no longer considered to be in the food court at that time Li.
If y groups arrive at the same time and x groups have already arrived before that, they will be the x+1th ~ x+yth earliest groups. The order inside the y groups is not important. Your program should return same value for the arrival times of the x+1th ~ x+yth earliest group, that is, the time when the y groups arrive at.
The first line contains an integer n, representing the number of the group today.
The following n lines represent the information about each group. Each of the line consists of:
After those n lines, there will be a line containing only one integer m, representing the number of the queries.
The following m lines represent m queries separately. Each line could consist of one of the following:
The four types of queries above are corresponding to the four mentioned in the description section.
It’s guaranteed that:
Also, for any group i:
You need to print the information according to the queries in the input.