Alike Tables

No attempts yetTime limit1sMemory limit128 MB

Problem

An n×mn \times m array is filled with integers that are all different from one another. Two operations are allowed on such an array.

  1. Interchange two rows.
  2. Interchange two columns.

Two arrays are alike if one of them can be obtained from the other by a sequence of those two operations. Given several pairs of arrays, decide for each pair whether the two arrays are alike.

Input

The first line contains an integer tt (1t101 \le t \le 10), the number of pairs of arrays.

The first line of each pair contains two integers nn and mm (1n10001 \le n \le 1000, 1m10001 \le m \le 1000) separated by a single space, the number of rows and the number of columns. The next nn lines contain the rows of the first array in order, and the nn lines after that contain the rows of the second array in order. Each of those lines contains mm integers between 1000000-1000000 and 10000001000000, inclusive. Inside one array all numbers are different.

Output

Print tt lines. Line kk contains YES if the two arrays of the kk-th pair are alike, and NO otherwise. Print in capital letters only.