Tokens

아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

We are given a three-dimensional, long and thin board consisting of unit cubes arranged into an A×B×CA \times B \times C cuboid. Every cell can be described by a triple of integers (i,j,k)(i, j, k), where 1iA1 \leq i \leq A, 1jB1 \leq j \leq B and 1kC1 \leq k \leq C. For every cell we know how many tokens are there initially --- in cell (i,j,k)(i, j, k) there are a_i,j,ka\_{i, j, k} of them. In one move we can take one cell that has at least one token and move this token to one of cells (i+1,j,k)(i+1, j, k), (i,j+1,k)(i, j+1, k) or (i,j,k+1)(i, j, k+1), provided that such cell exists.

Moreover, for every cell we are given a number b_i,j,kb\_{i, j, k}. Your task is to determine whether it is possible to perform some number of moves (possibly zero), so that for every cell (i,j,k)(i, j, k) number of tokens that end up there is exactly b_i,j,kb\_{i, j, k}.

입력

First line contains an integer tt (1t10,0001 \leq t \leq 10\\,000), denoting the number of testcases. 

Then descriptions of tt testcases follow. Each of them starts with a line containing three integers AA, BB, CC (1A10,0001 \leq A \leq 10\\,000, 1B,C61 \leq B, C \leq 6), denoting dimensions of the board. Then there are AA blocks of BB rows. Each of these rows contains CC numbers --- kk-th number in jj-th row of ii-th block is a_i,j,ka\_{i, j, k} (0a_i,j,k10120 \leq a\_{i, j, k} \leq 10^{12} ). Then, in analogous format, numbers b_i,j,kb\_{i, j, k} are given (0b_i,j,k10120 \leq b\_{i, j, k} \leq 10^{12}).

Every testcase contains 2A2A blocks in total. Every two consecutive blocks are separated by an empty line for the sake of readability. Within every testcase, the sum of values a_i,j,ka\_{i, j, k} is equal to the sum of values b_i,j,kb\_{i, j, k}.

Sum of values of AA over all testcases will not exceed 10,00010\\,000.

출력

Output should contain exactly tt lines, one per each testcase. kk-th line should contain a word TAK if in kk-th testcase it is possible to find a required sequence of moves from the initial to the final state, or a word NIE otherwise.

힌트

Explanation to second sample test: Below we present sequence of moves leading from the initial to the final state:

2 2        2 2        2 1        2 1        1 1        1 1        1 1
2 1        2 0        2 1        1 1        2 1        1 2        1 2
      ->         ->         ->         ->         ->         ->   
2 1        2 1        2 1        2 1        2 1        2 1        1 2
1 1        1 2        1 2        2 2        2 2        2 2        2 2