Despite everything going on in the world, you must still attend online school. Alas, you find yourself in a Zoom call about PHE. Due to the obvious, you become bored and start to think about the upcoming classes in the day. Your next class is coding. Your teacher, Dr. Bruce, has an interesting way to keep students focused. He will generate values using his method way to determine which kids to call on.
Your class contains
After, he will determine who to call on using one of the following queries:
1 w
: Find the maximum element of column
2 w
: Find the minimum element of column
3 w
: Find the maximum element of row
4 w
: Find the minimum element of row
You will be given all these values and
Input Specification
The first line of input will contain positive integer
The second line of input will contain array
The third line of input will contain array
The fourth line of input will contain positive integer
The next
Output Specification
On the
Constraints
Note that you will NOT be required to pass all the samples to receive points.
Subtask 1 [20%]
Subtask 2 [80%]
No additional constraints.
Sample Input
5
1 4 5 10 2
2 3 6 7 8
3
1 2
2 2
3 5
Sample Output
8
4
10
Explanation for Sample
The grid looks like this:
2 4 5 10 2
3 4 5 10 3
6 6 6 10 6
7 7 7 10 7
8 8 8 10 8
For the first query, the maximum element in column
Comments