Tudor likes ice cream cones!
One day, Tudor travels to an ice cream convention to eat ice cream. There are
Each of the stands charges a certain price for ice cream, which Tudor interprets as a signal of the quality of the ice cream. Tudor has strong flavor preferences and will decide to order ice cream from two stands within certain flavor constraints, choosing to either order from the two stands with the highest price, in the event he wishes to try some gourmet ice cream, or the two stands with the lowest price, in the event he wishes to save on money.
As the convention goes on, stands may change their prices. Tudor's flavor preferences may also change. Help Tudor eat ice cream!
Input Specification
The first line contains two positive integers,
The next line contains
Each of the next
If the first integer in the line is 1, the next two integers are
If the first integer in the line is 2, the next two integers are
If the first integer in the line is 3, the next two integers are
Output Specification
For each query, output the desired cost on a separate line.
Sample Data ZIP
Click here for ZIP.
Sample Input
4 4
1 4 2 5
2 1 1
2 7 7
1 3 6
3 6 5
Sample Output
5
7
6
Comments