The only number of the first line, T, (1 <= T <= 20) is the number of different test cases to be solved. T input blocks follow, which describe different independent test cases.
The first line of a block, contains two integers R, C (1 <= R,C <= 50), the number of rows and columns of the city map, respectively. Next R lines, each contains C non-negative integers, 0 <= Hij <= 1000, describing the building heights. The first entry is the leftmost building in the uppermost row. The coordinates of the starting and ending points are given next; the row coordinates come first in each line.
The lower and rightmost intersection is (R,C), while the opposite intersection is (0, 0).
Followed is A, (0 <= A <= 100), the number of mobile antennas. Next A lines describe the antennas by three numbers, r, c, (0 <= r <= R, 0 <= c <= C), and h, (0 <= h <= 1000). It means that there is an antenna with height h at the intersection (r, c).