In Byteland, a new institution has been founded to study how similar the country's various regions are to one another. The map of the country is an n×m rectangle made up of n⋅m unit squares. Each square is a province, and every province is assigned exactly one natural number describing a characteristic feature (for example, 1 for coal deposits, 2 for lakes, and so on).
Two regions are called k-similar if, among all pairs of corresponding provinces, at most k pairs have differing features (all the others are identical). Given the map, you must answer queries asking whether two given regions are k-similar.
For example, consider the following two 3×3 regions:
| 1 | 1 | 3 |
| 5 | 2 | 3 |
| 6 | 2 | 8 |
| 9 | 1 | 3 |
| 5 | 1 | 3 |
| 6 | 2 | 8 |
The two regions above are 2-similar and 3-similar, but they are neither 1-similar nor 0-similar.
The first line contains three integers n, m, q (1≤n,m≤200, 1≤q≤20000): the number of rows and columns of the map and the number of queries. Each of the next n lines describes the map; line i+1 contains m integers ai,1,…,ai,m (1≤ai,j≤100), where ai,j is the feature of the province in row i, column j (rows and columns are numbered from 1).
Each of the next q lines contains one query as seven integers x1 y1 x2 y2 w h k (0≤k≤1000, 1≤w≤m, 1≤h≤n). The two regions are rectangles whose top-left province lies at (column x1, row y1) and (column x2, row y2) respectively, each spanning w columns across and h rows down; their bottom-right provinces are therefore at (column x1+w−1, row y1+h−1) and (column x2+w−1, row y2+h−1). Both regions lie entirely inside the map. Decide whether the two regions are k-similar.
Print q lines, one per query: TAK if the two regions are k-similar, or NIE otherwise.