- 题目提供者 洛谷OnlineJudge
- 评测方式 云端评测
- 标签 模拟 POI 2009 高性能
- 难度 提高+/省选-
- 时空限制 1000ms / 128MB
Let us consider an array of size filled with pairwise different integers.
The following operations are allowed on the array:
interchanging two rows, interchanging two columns.
We call two arrays alike if one of them can be obtained from the other by a sequence of aforementioned operations.
Write a programme that for a given set of pairs of arrays tells which pairs are alike.
The first line of the standard input contains one integer () denoting the number of pairs of arrays.
Then descriptions of successive array pairs follow in subsequent lines.
Each description starts with a line holding two integers and (), separated by a single space, that denote the common number of rows and columns of the arrays, respectively.
The lines that follow describe the first array.
In the -th of them there are integers (), separated by single spaces…输出格式：
Your programme should print out lines to the standard output.
The -th of these should hold one word: "TAK" (yes in Polish) if the arrays of the -th pair are alike, or "NIE" (no in Polish) otherwise.