eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків

Table

Let us consider an array of size \textbf{n}×\textbf{m} filled with \textbf{pair wise different} integers. The following operations are allowed on the array: \begin{enumerate} \item Interchanging two rows, \item Interchanging two columns. \end{enumerate} We call two arrays alike if one of them can be obtained from the other by a sequence of the above two operations. Write a program that for a given set of pairs of arrays tells which pairs are alike. \InputFile The first line of the standard input contains an integer \textbf{t} (\textbf{1} ≤ \textbf{t} ≤ \textbf{10}) denoting the number of test cases which represent the number of pairs of arrays. The first line of each test case holds two integers \textbf{n} and \textbf{m} (\textbf{1} ≤ \textbf{n} ≤ \textbf{1000} and \textbf{1 }≤ \textbf{m} ≤ \textbf{1000}), separated by a single space. \textbf{n} and \textbf{m} denote the number of rows and columns of the arrays, respectively. The next \textbf{n} lines represent \textbf{n} rows of the first array and the following \textbf{n} lines represent \textbf{n} rows of the second array. Each line holds m array items where each values between \textbf{-1000000} and \textbf{1000000} inclusive. All numbers occurring in either of the arrays are pair wise different. \OutputFile Your program should print out \textbf{t} lines to the standard output. The \textbf{k}-th of these should hold one word: "\textbf{YES}" if the arrays of the \textbf{k}-th pair are alike, or "\textbf{NO}" otherwise (in capital letter only).
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
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
Вихідні дані #1
YES
NO
Джерело ACM-ICPC Malaysia al-Khawārizmī Programming Contest 2011