Consider an table filled with distinct integers. The following operations can be performed on the table:
Swapping two rows.
Swapping two columns.
We say that two tables are similar if, by applying some sequence of the above operations to the first table, we can obtain the second table.
Write a program that determines for a given set of table pairs which pairs contain similar tables.
输入格式
The first line of standard input contains a single integer (), representing the number of table pairs. The subsequent lines describe the table pairs.
Each table pair description starts with a line containing two integers and (), separated by a single space, representing the number of rows and columns of both tables.
The next lines contain the description of the first table. The -th of these lines contains integers (), separated by single spaces, representing the numbers in the -th row of the first table.
The next lines contain the description of the second table. The -th of these lines contains integers (), separated by single spaces, representing the numbers in the -th row of the second table.
All numbers in a single table are distinct.
输出格式
Your program should print lines to standard output. The -th of these lines should contain the word "TAK" if the tables in the -th input pair are similar, and "NIE" otherwise.