An n×m array is filled with integers that are all different from one another. Two operations are allowed on such an array.
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.
The first line contains an integer t (1≤t≤10), the number of pairs of arrays.
The first line of each pair contains two integers n and m (1≤n≤1000, 1≤m≤1000) separated by a single space, the number of rows and the number of columns. The next n lines contain the rows of the first array in order, and the n lines after that contain the rows of the second array in order. Each of those lines contains m integers between −1000000 and 1000000, inclusive. Inside one array all numbers are different.
Print t lines. Line k contains YES if the two arrays of the k-th pair are alike, and NO otherwise. Print in capital letters only.