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.

Source: codeforces | Difficulty: MEDIUM
Tags: Implementation


Solutions:
N = int(input())
map_1 = [list(input()) for i in range(N)]
map_2 = [list(input()) for i in range(N)]
maps = list()
maps.append([[map_2[i][j] for j in range(N)] for i in range(N)])
maps.append([[map_2[i][N - 1 - j] for j in range(N)] for i in range(N)])
maps.append([[map_2[N - 1 - i][j] for j in range(N)] for i in range(N)])
maps.append([[map_2[N - 1 - i][N - 1 - j] for j in range(N)] for i in range(N)])
maps.append([[map_2[j][i] for j in range(N)] for i in range(N)])
maps.append([[map_2[j][N - 1 - i] for j in range(N)] for i in range(N)])
maps.append([[map_2[N - 1 - j][i] for j in range(N)] for i in range(N)])
maps.append([[map_2[N - 1 - j][N - 1 - i] for j in range(N)] for i in range(N)])
print(('No', 'Yes')[any((map_1 == el for el in maps))])


import copy

def rotate90(n, f):
	return [[f[n - j - 1][i] for j in range(n)] for i in range(n)]

def fliphor(n, f):
	return [[f[i][n - j - 1] for j in range(n)] for i in range(n)]

def flipver(n, f):
	return [[f[n - i - 1][j] for j in range(n)] for i in range(n)]

def eq(n, f, g):
	for i in range(n):
		for j in range(n):
			if f[i][j] != g[i][j]:
				return False
	return True
n = int(input())
f = [list(input()) for i in range(n)]
g = [list(input()) for i in range(n)]
for doflipv in range(2):
	for dofliph in range(2):
		for nrot in range(4):
			h = copy.deepcopy(f)
			if dofliph == 1:
				h = fliphor(n, h)
			if doflipv == 1:
				h = flipver(n, h)
			for i in range(nrot):
				h = rotate90(n, h)
			if eq(n, h, g):
				print('Yes')
				exit(0)
print('No')


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')


def rotate_90(a):
	b = []
	for x in range(len(a)):
		l = []
		for y in range(len(a) - 1, -1, -1):
			l.append(a[y][x])
		b.append(l)
	return b

def flip(a):
	b = []
	for x in range(len(a)):
		l = []
		for y in range(len(a) - 1, -1, -1):
			l.append(a[x][y])
		b.append(l)
	return b
n = int(input())
l = []
for i in range(n):
	a = input()
	l2 = []
	for i2 in a:
		l2.append(i2)
	l.append(l2)
l2 = []
for i in range(n):
	a = input()
	l3 = []
	for i2 in a:
		l3.append(i2)
	l2.append(l3)
d = 'no'
for i in range(4):
	l = rotate_90(l)
	if l == l2:
		d = 'yes'
l = flip(l)
for i in range(4):
	l = rotate_90(l)
	if l == l2:
		d = 'yes'
print(d)


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')


N = int(input())
map1 = []
map2 = []
for _ in range(N):
	map1 += [input()]
for _ in range(N):
	map2 += [input()]
equal1 = True
equal2 = True
equal3 = True
equal4 = True
equal5 = True
equal6 = True
equal7 = True
equal8 = True
for i in range(N):
	for j in range(N):
		if map1[i][j] != map2[i][j]:
			equal1 = False
		if map1[i][j] != map2[j][N - i - 1]:
			equal2 = False
		if map1[i][j] != map2[N - i - 1][N - j - 1]:
			equal3 = False
		if map1[i][j] != map2[N - j - 1][N - i - 1]:
			equal4 = False
		if map1[i][j] != map2[i][N - j - 1]:
			equal5 = False
		if map1[i][j] != map2[N - i - 1][j]:
			equal6 = False
		if map1[i][j] != map2[N - j - 1][i]:
			equal7 = False
		if map1[i][j] != map2[j][i]:
			equal8 = False
if equal1 or equal2 or equal3 or equal4 or equal5 or equal6 or equal7 or equal8:
	print('yes')
else:
	print('no')


def rotate(L):
	L1 = ['' for i in range(n)]
	for i in range(n):
		for j in range(n):
			L1[n - j - 1] += L[i][j]
	return L1

def flip_v(L):
	L1 = []
	for i in range(n):
		L1.append(L[i][::-1])
	return L1

def flip_h(L):
	L1 = []
	for i in range(n):
		L1.append(L[n - i - 1])
	return L1
n = int(input())
L = []
M = []
for i in range(n):
	L.append(input())
for i in range(n):
	M.append(input())
L1 = rotate(L)
L2 = rotate(L1)
L3 = rotate(L2)
L4 = flip_v(L)
L5 = flip_h(L)
L6 = rotate(L4)
L7 = rotate(L6)
L8 = rotate(L7)
L9 = rotate(L5)
L10 = rotate(L9)
L11 = rotate(L10)
if L == M or L1 == M or L2 == M or (L3 == M) or (L4 == M) or (L5 == M) or (L6 == M) or (L7 == M) or (L8 == M) or (L9 == M) or (L10 == M) or (L11 == M):
	print('Yes')
else:
	print('No')


import copy
lista = []
listb = []
temp = []
a = int(input())
flag = 0
mark = 0
for i in range(0, a):
	str = input()
	for j in range(0, a):
		temp.append(str[j])
	lista.append(temp)
	temp = []
for i in range(0, a):
	str = input()
	for j in range(0, a):
		temp.append(str[j])
	listb.append(temp)
	temp = []
listacpy = copy.deepcopy(lista)
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
for i in range(0, a):
	for j in range(0, a):
		listacpy[a - 1 - j][i] = lista[i][j]
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
for i in range(0, a):
	for j in range(0, a):
		listacpy[a - 1 - i][a - 1 - j] = lista[i][j]
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
for i in range(0, a):
	for j in range(0, a):
		listacpy[j][a - 1 - i] = lista[i][j]
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
listtemp = copy.deepcopy(lista)
for i in range(0, a):
	for j in range(0, a):
		lista[i][j] = listtemp[i][a - 1 - j]
listacpy = copy.deepcopy(lista)
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
for i in range(0, a):
	for j in range(0, a):
		listacpy[a - 1 - j][i] = lista[i][j]
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
for i in range(0, a):
	for j in range(0, a):
		listacpy[a - 1 - i][a - 1 - j] = lista[i][j]
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
mark = 0
for i in range(0, a):
	for j in range(0, a):
		listacpy[j][a - 1 - i] = lista[i][j]
for i in range(0, a):
	for j in range(0, a):
		if listacpy[i][j] != listb[i][j]:
			mark = 1
			break
	if mark == 1:
		break
if mark == 0:
	flag = 1
if flag == 1:
	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()


import copy
n = int(input())
flg = 0
mat1 = []
mat2 = []
mats = []
for i in range(0, n):
	mat1.append(tuple(input().strip()))
for i in range(0, n):
	mat2.append(tuple(input().strip()))
mats.append(mat2)
matu = copy.copy(mat2)
matv = copy.copy(mat2)
matv = list(zip(*matv))
mats.append(matv)
mattem = copy.copy(matu)
for i in range(0, 3):
	mattem = list(zip(*list(reversed(mattem))))
	mats.append(mattem)
mattem = copy.copy(matv)
for i in range(0, 3):
	mattem = list(zip(*list(reversed(mattem))))
	mats.append(mattem)
flg = 0
for cmat in mats:
	flg2 = 1
	for ri in range(0, n):
		if cmat[ri] != mat1[ri]:
			flg2 = 0
			break
	if flg2 == 1:
		flg = 1
		break
if flg == 1:
	print('Yes')
else:
	print('No')


def rotate(li):
	newli = []
	for x in range(0, n):
		newli.append([])
		newli[x] = li[x].copy()
	for x in range(0, n):
		for y in range(0, n):
			newli[x][y] = li[n - 1 - y][x]
	return newli

def flipV(li):
	newli = []
	for x in range(0, n):
		newli.append([])
		newli[x] = li[x].copy()
	newli.reverse()
	return newli

def flipH(li):
	newli = []
	for x in range(0, n):
		newli.append([])
		newli[x] = li[x].copy()
	for x in range(0, n):
		newli[x].reverse()
	return newli
n = int(input())
(li1, li2, li3, templi) = ([], [], [], [])
for x in range(0, n):
	li1.append([])
	li2.append([])
	li3.append([])
	templi.append([])
	li1[x] = list(input())
for x in range(0, n):
	li2[x] = list(input())
if li1 == li2:
	print('Yes')
	exit()
templi = flipH(li2)
if li1 == templi:
	print('Yes')
	exit()
templi = flipV(li2)
if li1 == templi:
	print('Yes')
	exit()
templi = rotate(li2)
if li1 == templi:
	print('Yes')
	exit()
templi = rotate(templi)
if li1 == templi:
	print('Yes')
	exit()
templi = rotate(templi)
if li1 == templi:
	print('Yes')
	exit()
templi = flipH(li2)
templi = rotate(templi)
if li1 == templi:
	print('Yes')
	exit()
templi = rotate(templi)
if li1 == templi:
	print('Yes')
	exit()
templi = rotate(templi)
if li1 == templi:
	print('Yes')
	exit()
print('No')


def check():
	f = True
	for i in range(n):
		for j in range(n):
			if map1[i][j] != map2[i][j]:
				f = False
				break
	if f:
		return True
	f = True
	for i in range(n):
		for j in range(n):
			if map1[i][j] != map2[n - 1 - i][j]:
				f = False
				break
	if f:
		return True
	f = True
	for i in range(n):
		for j in range(n):
			if map1[i][j] != map2[i][n - 1 - j]:
				f = False
				break
	if f:
		return True

def rotate():
	wk1 = []
	for i in range(n):
		wk1.append([])
		for j in range(n):
			wk1[i].append(map1[i][j])
	for i in range(n):
		for j in range(n):
			map1[i][j] = wk1[j][n - 1 - i]
n = int(input())
map1 = []
for i in range(n):
	st = input()
	map1.append([])
	for j in st:
		map1[i].append(j)
map2 = []
for i in range(n):
	st = input()
	map2.append([])
	for j in st:
		map2[i].append(j)
f = False
for k in range(4):
	if check():
		f = True
		break
	rotate()
if f:
	print('Yes')
else:
	print('No')


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())
map1 = [list(input()) for i in range(n)]
map2 = [list(input()) for i in range(n)]

def vFlip(m):
	return [list(reversed(i)) for i in m]

def hFlip(m):
	return list(reversed(m))

def rotate(m):
	return list(zip(*reversed(m)))

def check():
	global map1
	for i in range(4):
		if map1 == map2:
			return True
		if vFlip(map1) == map2:
			return True
		if hFlip(map1) == map2:
			return True
		if vFlip(hFlip(map1)) == map2:
			return True
		map1 = rotate(map1)
	return False
print('YES' if check() else 'NO')


from copy import deepcopy

def GenerateMap(n):
	positions = []
	for i in range(0, n):
		positions.append([])
	return positions

def Rotate(a, times):
	rotated = []
	for i in range(0, n):
		rotated.append([])
	counter = len(a)
	for i in rotated:
		counter -= 1
		for j in a:
			i.append(j[counter])
	for i in range(0, times - 1):
		counter = len(a)
		x = deepcopy(rotated)
		for j in rotated:
			j.clear()
			counter -= 1
			for k in x:
				j.append(k[counter])
	return rotated

def Flip(a):
	flipped = []
	for i in reversed(a):
		flipped.append(i)
	return flipped

def CheckMaps(a, b):
	if a == b:
		return 'Yes'
	elif Rotate(a, 1) == b:
		return 'Yes'
	elif Rotate(a, 2) == b:
		return 'Yes'
	elif Rotate(a, 3) == b:
		return 'Yes'
	elif Flip(a) == b:
		return 'Yes'
	elif Flip(Rotate(a, 1)) == b:
		return 'Yes'
	elif Flip(Rotate(a, 2)) == b:
		return 'Yes'
	elif Flip(Rotate(a, 3)) == b:
		return 'Yes'
	else:
		return 'No'
n = int(input())
a = GenerateMap(n)
b = GenerateMap(n)
for i in range(0, n):
	x = []
	x[:] = input()
	a[i] = x
for i in range(0, n):
	x = []
	x[:] = input()
	b[i] = x
print(CheckMaps(a, b))


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf, log2, sqrt, log10
from bisect import bisect_right, bisect_left
from statistics import mode
from string import ascii_uppercase
cases = int(input())
matrix1 = []
for _ in range(cases):
	matrix1.append(list(input()))
matrix2 = []
for _ in range(cases):
	matrix2.append(list(input()))

def transpose(matrix):
	return [list(x) for x in zip(*matrix)]

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

def reverse_column(matrix):
	return [x[::-1] for x in matrix]

def rotate_90(matrix):
	return reverse_row(transpose(matrix))

def rotate_180(matrix):
	return reverse_row(reverse_column(matrix))

def rotate_270(matrix):
	return reverse_column(transpose(matrix))
if matrix1 == matrix2 or matrix1 == reverse_row(matrix2) or matrix1 == reverse_column(matrix2) or (matrix1 == rotate_90(matrix2)) or (matrix1 == rotate_180(matrix2)) or (matrix1 == rotate_270(matrix2)):
	print('Yes')
	exit()
matrix2 = reverse_row(matrix2)
if matrix1 == matrix2 or matrix1 == reverse_row(matrix2) or matrix1 == reverse_column(matrix2) or (matrix1 == rotate_90(matrix2)) or (matrix1 == rotate_180(matrix2)) or (matrix1 == rotate_270(matrix2)):
	print('Yes')
	exit()
matrix2 = reverse_column(matrix2)
if matrix1 == matrix2 or matrix1 == reverse_row(matrix2) or matrix1 == reverse_column(matrix2) or (matrix1 == rotate_90(matrix2)) or (matrix1 == rotate_180(matrix2)) or (matrix1 == rotate_270(matrix2)):
	print('Yes')
	exit()
matrix2 = transpose(matrix2)
if matrix1 == matrix2 or matrix1 == reverse_row(matrix2) or matrix1 == reverse_column(matrix2) or (matrix1 == rotate_90(matrix2)) or (matrix1 == rotate_180(matrix2)) or (matrix1 == rotate_270(matrix2)):
	print('Yes')
	exit()
else:
	print('No')


N = int(input())
m1 = []
m2 = []
ms = []
for n in range(N):
	m1.append(input())
for n in range(N):
	m2.append(input())
ms = [m2, [x[::-1] for x in m2], [x for x in reversed(m2)]]
a = []
for m in ms:
	a.append(m)
	a.append([x[::-1] for x in reversed(m)])
	a.append([''.join((m[j][i] for j in range(N - 1, -1, -1))) for i in range(N)])
	a.append([''.join((m[j][i] for j in range(N))) for i in range(N - 1, -1, -1)])
ms = a
print(['NO', 'YES'][m1 in ms])


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())
a = []
b = []
for i in range(n):
	a.append(input())
for i in range(n):
	b.append(input())

def h(d):
	c = []
	for i in range(n):
		c.append(d[n - i - 1])
	return c

def r(d):
	c = []
	for i in range(n):
		temp = ''
		for j in range(n):
			temp += d[j][n - i - 1]
		c.append(temp)
	return c
yes = 0
for i in range(4):
	if a == b:
		print('YES')
		yes = 1
		break
	a = r(a)
if yes == 0:
	a = h(a)
	for i in range(4):
		if a == b:
			print('YES')
			yes = 1
			break
		a = r(a)
if yes == 0:
	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))