#luoguP3492. [POI 2009] TAB-Arrays
[POI 2009] TAB-Arrays
本题没有可用的提交语言。
题目描述
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.
2
4 3
1 2 3
4 5 6
7 8 9
10 11 12
11 10 12
8 7 9
5 4 6
2 1 3
2 2
1 2
3 4
5 6
7 8
TAK
NIE