
60  ZOJ Monthly, June 2007  1002
Given an n*n matrix A, whose entries Ai,j are integer numbers ( 1 <= i <= n, 1 <= j <= n ). An operation FIND the minimun number in a given ssubmatrix. Input The first line of the input contains a single integer T , the number of test cases. For each test case, the first line contains one integer n (1 <= n <= 300), which is the sizes of the matrix, respectively. The next n lines with n integers each gives the elements of the matrix. The next line contains a single integer N (1 <= N <= 1,000,000), the number of queries. The next N lines give one query on each line, with four integers r1, c1, r2, c2 (1 <= r1 <= r2 <= n, 1 <= c1 <= c2 <= n), which are the indices of the upperleft corner and lowerright corner of the submatrix in question. Output For each test case, print N lines with one number on each line, the required minimum integer in the submatrix. Sample Input
1 Sample Output
1 Author: PENG, Peng 