The stardate is 1977 and the science and art of detecting Death Stars is in its infancy. Princess Heidi has received information about the stars in the nearby solar system from the Rebel spies and now, to help her identify the exact location of the Death Star, she needs to know whether this information is correct. 

Two rebel spies have provided her with the maps of the solar system. Each map is an N × N grid, where each cell is either occupied by a star or empty. To see whether the information is correct, Heidi needs to know whether the two maps are of the same solar system, or if possibly one of the spies is actually an Empire double agent, feeding her false information.

Unfortunately, spies may have accidentally rotated a map by 90, 180, or 270 degrees, or flipped it along the vertical or the horizontal axis, before delivering it to Heidi. If Heidi can rotate or flip the maps so that two of them become identical, then those maps are of the same solar system. Otherwise, there are traitors in the Rebel ranks! Help Heidi find out.


-----Input-----

The first line of the input contains one number N (1 ≤ N ≤ 10) – the dimension of each map. Next N lines each contain N characters, depicting the first map: 'X' indicates a star, while 'O' indicates an empty quadrant of space. Next N lines each contain N characters, depicting the second map in the same format.


-----Output-----

The only line of output should contain the word Yes if the maps are identical, or No if it is impossible to match them by performing rotations and translations.


-----Examples-----
Input
4
XOOO
XXOO
OOOO
XXXX
XOOO
XOOO
XOXO
XOXX

Output
Yes

Input
2
XX
OO
XO
OX

Output
No



-----Note-----

In the first test, you can match the first map to the second map by first flipping the first map along the vertical axis, and then by rotating it 90 degrees clockwise.

Difficulty: MEDIUM

Solutions:
def flipH(A, N):
	B = [[0 for i in range(N)] for j in range(N)]
	for i in range(N):
		for j in range(N):
			B[i][j] = A[i][N - j - 1]
	return B

def flipV(A, N):
	B = [[0 for i in range(N)] for j in range(N)]
	for i in range(N):
		for j in range(N):
			B[i][j] = A[N - i - 1][j]
	return B

def rotate90(A):
	ans = zip(*A[::-1])
	ans = list(map(list, ans))
	return ans

def check(A, B, N):
	for i in range(N):
		for j in range(N):
			if A[i][j] != B[i][j]:
				return False
	return True
N = int(input())
A = []
X = []
for i in range(N):
	A.append(list(input()))
for i in range(N):
	X.append(list(input()))
B = flipH(A, N)
C = flipV(A, N)
flag = False
for i in range(4):
	if check(A, X, N) or check(B, X, N) or check(C, X, N):
		flag = True
		break
	else:
		A = rotate90(A)
		B = rotate90(B)
		C = rotate90(C)
if flag:
	print('Yes')
else:
	print('No')


def check(x, y):
	return ''.join([''.join(s) for s in x]) == ''.join([''.join(s) for s in y])
re = int(input())
a = [list(input()) for i in range(re)]
b = [list(input()) for i in range(re)]
for i in range(4):
	for j in range(2):
		if check(a, b):
			print('Yes')
			return
		b = b[::-1]
	for j in range(2):
		if check(a, b):
			print('Yes')
			return
		b = [s[::-1] for s in b]
	c = [['' for t in range(re)] for u in range(re)]
	for t in range(re):
		for u in range(re):
			c[t][u] = b[u][re - t - 1]
	b = c[:]
	if check(a, b):
		print('Yes')
		return
print('No')


from itertools import chain, combinations, permutations

def powerset(iterable):
	xs = list(iterable)
	return chain.from_iterable((combinations(xs, n) for n in range(len(xs) + 1)))
n = int(input())
cl1 = []
cl2 = []
for i in range(n):
	s = input()
	a = []
	for j in range(n):
		a.append(s[j])
	cl1.append(a)
for i in range(n):
	s = input()
	a = []
	for j in range(n):
		a.append(s[j])
	cl2.append(a)

def copy(m):
	res = []
	for i in range(n):
		a = []
		for j in range(n):
			a.append(m[i][j])
		res.append(a)
	return res

def pow(m):
	res = []
	for i in range(n):
		a = []
		for j in range(n):
			a.append(m[n - 1 - j][i])
		res.append(a)
	return res

def vert(m):
	res = []
	for i in range(n):
		res.append(m[i][::-1])
	return res

def gor(m):
	res = []
	for i in range(n):
		a = []
		for j in range(n):
			a.append(m[i][n - 1 - j])
		res.append(a)
	return res
comblist = [[1], []]
cm = [pow, pow, pow, vert, gor]
cm = list(powerset(cm))
res = False
if cl1 == cl2:
	res = True
else:
	for x in cm:
		for y in permutations(x):
			t = copy(cl1)
			for z in y:
				t = z(t)
			if t == cl2:
				res = True
if res:
	print('Yes')
else:
	print('No')


n = int(input())
ns = []
for i in range(n):
	s = input()
	ns.append(s)
ns2 = []
for i in range(n):
	s = input()
	ns2.append(s)

def rotate(i, j):
	return (j, n - 1 - i)

def flip(i, j):
	return (j, i)

def main():
	same = True
	for i in range(n):
		for j in range(n):
			if ns[i][j] != ns2[i][j]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = rotate(i, j)
			if ns[i][j] != ns2[a][b]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = rotate(i, j)
			(a, b) = rotate(a, b)
			if ns[i][j] != ns2[a][b]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = rotate(i, j)
			(a, b) = rotate(a, b)
			(a, b) = rotate(a, b)
			if ns[i][j] != ns2[a][b]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = flip(i, j)
			if ns[a][b] != ns2[i][j]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = rotate(i, j)
			(a, b) = flip(a, b)
			if ns[i][j] != ns2[a][b]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = rotate(i, j)
			(a, b) = rotate(a, b)
			(a, b) = flip(a, b)
			if ns[i][j] != ns2[a][b]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	same = True
	for i in range(n):
		for j in range(n):
			(a, b) = rotate(i, j)
			(a, b) = rotate(a, b)
			(a, b) = rotate(a, b)
			(a, b) = flip(a, b)
			if ns[i][j] != ns2[a][b]:
				same = False
				break
		if same == False:
			break
	if same:
		return True
	else:
		return False
if main():
	print('Yes')
else:
	print('No')


from sys import stdin
n = int(stdin.readline())

def eq(m1, m2):
	for i in range(n):
		if m1[i] != m2[i]:
			return False
	return True

def fleq(m1, m2):
	return eq(m1, m2) or eq(m1, fliph(m2)) or eq(m1, flipv(m2))

def fliph(m):
	return [row[::-1] for row in m]

def flipv(m):
	return m[::-1]

def rot(m):
	mr = ['' for _ in range(n)]
	for i in range(n):
		x = ''
		for j in range(n):
			x = x + m[j][n - i - 1]
		mr[i] = x
	return mr
u = [stdin.readline()[:-1] for _ in range(n)]
v = [stdin.readline()[:-1] for _ in range(n)]
v90 = rot(v)
v180 = rot(v90)
v270 = rot(v180)
if fleq(u, v) or fleq(u, v90) or fleq(u, v180) or fleq(u, v270):
	print('Yes')
else:
	print('No')


def rotate90Clockwise(A):
	N = len(A[0])
	for i in range(N // 2):
		for j in range(i, N - i - 1):
			temp = A[i][j]
			A[i][j] = A[N - 1 - j][i]
			A[N - 1 - j][i] = A[N - 1 - i][N - 1 - j]
			A[N - 1 - i][N - 1 - j] = A[j][N - 1 - i]
			A[j][N - 1 - i] = temp

def check(A, B):
	c1 = 0
	c2 = 0
	for i in range(N):
		for j in range(N):
			if A[i][j] == B[N - 1 - i][j]:
				c1 += 1
			if A[i][j] == B[i][N - 1 - j]:
				c2 += 1
	if c1 == N ** 2 or c2 == N ** 2:
		return True
	else:
		return False
N = int(input())
A = []
for i in range(N):
	a = input()
	aa = []
	for j in range(N):
		aa.append(a[j])
	A.append(aa)
B = []
for j in range(N):
	b = input()
	bb = []
	for j in range(N):
		bb.append(b[j])
	B.append(bb)
flag = False
if A == B:
	flag = True
if check(A, B):
	flag = True
rotate90Clockwise(A)
if A == B:
	flag = True
if check(A, B):
	flag = True
rotate90Clockwise(A)
if A == B:
	flag = True
if check(A, B):
	flag = True
rotate90Clockwise(A)
if A == B:
	flag = True
if check(A, B):
	flag = True
if flag:
	print('Yes')
else:
	print('No')


import os, sys
from io import BytesIO, IOBase
from copy import deepcopy

def main():
	n = rint()
	(a1, a2, ans) = (Matrix(n, n, rstr_2d(n)), Matrix(n, n, rstr_2d(n)), [])
	for i in range(4):
		ans.extend([a1.rotate(), a1.fliph(), a1.flipv(), a1.fliph(), a1.flipv()])
	print(['No', 'Yes'][a2.mat in ans])

class Matrix:

	def __init__(self, r, c, mat=None, id=None):
		(self.r, self.c) = (r, c)
		if mat != None:
			self.mat = deepcopy(mat)
		else:
			self.mat = [[0 for i in range(c)] for j in range(r)]

	def __add__(self, other):
		mat0 = Matrix(self.r, self.c)
		for i in range(self.r):
			for j in range(self.c):
				mat0.mat[i][j] = self.mat[i][j] + other.mat[i][j]
		return mat0

	def __mul__(self, other):
		mat0 = Matrix(self.r, other.c)
		for i in range(self.r):
			for j in range(other.c):
				for k in range(self.c):
					mat0.mat[i][j] += self.mat[i][k] * other.mat[k][j]
		return mat0

	def dot_mul(self, other):
		res = 0
		for i in range(self.r):
			for j in range(self.c):
				res += self.mat[i][j] * other.mat[j][i]
		return res

	def trace(self):
		res = 0
		for i in range(self.r):
			res += self.mat[i][i]
		return res

	def rotate(self):
		mat0 = Matrix(self.c, self.r)
		for i in range(self.r):
			for j in range(self.c):
				mat0.mat[j][self.r - (i + 1)] = self.mat[i][j]
		(self.mat, self.r, self.c) = (deepcopy(mat0.mat), self.c, self.r)
		return self.mat

	def flipv(self):
		mat0 = Matrix(self.r, self.c)
		for i in range(self.r):
			for j in range(self.c):
				mat0.mat[i][self.c - (j + 1)] = self.mat[i][j]
		self.mat = deepcopy(mat0.mat)
		return self.mat

	def fliph(self):
		mat0 = Matrix(self.r, self.c)
		for i in range(self.r):
			for j in range(self.c):
				mat0.mat[self.r - (i + 1)][j] = self.mat[i][j]
		self.mat = deepcopy(mat0.mat)
		return self.mat

	def mat_pow(self, mat, p, mod=None):
		sq = Matrix(mat.r, mat.r, id=1)
		while p:
			if p & 1:
				p -= 1
				sq = sq * mat
			p //= 2
			mat = mat * mat
		return sq.mat

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
BUFSIZE = 8192
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
rstr = lambda : input().strip()
rstrs = lambda : [str(x) for x in input().split()]
rstr_2d = lambda n: [list(rstr()) for _ in range(n)]
rint = lambda : int(input())
rints = lambda : [int(x) for x in input().split()]
rint_2d = lambda n: [rint() for _ in range(n)]
rints_2d = lambda n: [rints() for _ in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
main()


N = int(input())
s1 = [list(input()) for i in range(N)]
s2 = [list(input()) for i in range(N)]

def rotate(s):
	ret = [[None for i in range(N)] for j in range(N)]
	for i in range(N):
		for j in range(N):
			ret[i][j] = s[j][N - 1 - i]
	return ret

def v_mirror(s):
	return list(reversed(s))

def h_mirror(s):
	return [list(reversed(row)) for row in s]

def solve():
	global s1
	for i in range(4):
		if s1 == s2:
			return True
		if v_mirror(s1) == s2:
			return True
		if h_mirror(s1) == s2:
			return True
		if v_mirror(h_mirror(s1)) == s2:
			return True
		s1 = rotate(s1)
	return False
print('Yes' if solve() else 'No')


n = int(input())
f = lambda : ''.join((input() for i in range(n)))
(a, b) = (f(), f())
g = lambda k: k // n + n * (n - 1 - k % n)
e = lambda k: k
h = lambda k: n * (n - 1 - k // n) + k % n
v = lambda k: n * (k // n) + n - 1 - k % n
for i in (e, v, h):
	for j in [e, g, lambda k: g(g(k)), lambda k: g(g(g(k)))]:
		if all((a[k] == b[i(j(k))] for k in range(n * n))):
			exit(print('Yes'))
print('No')


def solve(board):
	n = len(board)
	ans = 0
	for i in range(n):
		for j in range(n):
			if board[i][j] is 'X':
				ans += 2 ** (i * n + j)
	return ans

def reverse_array(arr):
	for i in range(len(arr)):
		arr[i].reverse()

def rotate(matrix, degree):
	if degree == 0:
		return matrix
	elif degree > 0:
		return rotate(zip(*matrix[::-1]), degree - 90)
	else:
		return rotate(zip(*matrix)[::-1], degree + 90)

def make_list(board):
	board = list(board)
	arr = []
	for i in range(len(list(board))):
		arr.append(list(board[i]))
	return arr

def add_rotations(board, st):
	for i in range(4):
		st.add(solve(board))
		reverse_array(board)
		st.add(solve(board))
		reverse_array(board)
		board = make_list(rotate(board, 90))
n = int(input())
arr1 = []
arr2 = []
for _ in range(n):
	arr1.append(list(input().strip()))
for _ in range(n):
	arr2.append(list(input().strip()))
s = set()
s.add(solve(arr1))
add_rotations(arr1, s)
l1 = len(s)
s.add(solve(arr2))
add_rotations(arr2, s)
l2 = len(s)
if l1 == l2:
	print('Yes')
else:
	print('No')


n = int(input())
M1 = []
M2 = []
N1 = []
N2 = []
N90 = []
N180 = []
N270 = []
S = []
S90 = []
S180 = []
S270 = []
for k in range(n):
	N1.append([])
	N2.append([])
	N90.append([])
	N180.append([])
	N270.append([])
	S.append([])
	S90.append([])
	S180.append([])
	S270.append([])
for k in range(n):
	M1.append(input())
for k in range(n):
	M2.append(input())
for y in range(n):
	for x in range(n):
		if M1[y][x] == 'X':
			N1[y].append(1)
		else:
			N1[y].append(0)
for y in range(n):
	for x in range(n):
		if M2[y][x] == 'X':
			N2[y].append(1)
		else:
			N2[y].append(0)
for y in range(n):
	for x in range(n):
		N90[y].append(N1[x][n - 1 - y])
		N180[y].append(N1[n - 1 - y][n - 1 - x])
		N270[y].append(N1[n - 1 - x][y])
		S[y].append(N1[y][n - 1 - x])
		S90[y].append(N1[n - 1 - x][n - 1 - y])
		S180[y].append(N1[n - 1 - y][x])
		S270[y].append(N1[x][y])
if N2 == N1 or N2 == N90 or N2 == N180 or (N2 == N270) or (N2 == S) or (N2 == S90) or (N2 == S180) or (N2 == S270):
	print('Yes')
else:
	print('No')


N = int(input())
first = []
second = []
for i in range(N):
	first.append([s for s in input()])
for i in range(N):
	second.append([s for s in input()])

def rotate_90(matrix):
	return list(zip(*matrix[::-1]))

def flip(matrix):
	return matrix[::-1]

def compare_matrices(first, second):
	for i in range(N):
		for j in range(N):
			if first[i][j] != second[i][j]:
				return False
	return True

def wrap(first, second):
	if compare_matrices(first, second) == True:
		return 'Yes'
	hold_first = first[:]
	for _ in range(3):
		first = rotate_90(first)
		if compare_matrices(first, second) == True:
			return 'Yes'
	first = hold_first
	first = flip(first)
	if compare_matrices(first, second) == True:
		return 'Yes'
	for _ in range(3):
		first = rotate_90(first)
		if compare_matrices(first, second) == True:
			return 'Yes'
	return 'No'
print(wrap(first, second))