Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?

Given a n × n checkerboard. Each cell of the board has either character 'x', or character 'o'. Is it true that each cell of the board has even number of adjacent cells with 'o'? Two cells of the board are adjacent if they share a side.


-----Input-----

The first line contains an integer n (1 ≤ n ≤ 100). Then n lines follow containing the description of the checkerboard. Each of them contains n characters (either 'x' or 'o') without spaces.


-----Output-----

Print "YES" or "NO" (without the quotes) depending on the answer to the problem.


-----Examples-----
Input
3
xxo
xox
oxx

Output
YES

Input
4
xxxo
xoxo
oxox
xxxx

Output
NO

Source: codeforces | Difficulty: EASY
Tags: Implementation

Complete search


Solutions:
n = int(input())
a = ''
for i in range(n):
	b = input()
	a += b
if a == a[::-1]:
	print('YES')
else:
	print('NO')


import collections
import itertools
n = int(input())
m = collections.defaultdict(lambda : 'x')
for y in range(n):
	for (x, ch) in enumerate(input()):
		m[x, y] = ch
deltas = ((-1, 0), (0, -1), (1, 0), (0, 1))
for p in itertools.product(range(n), repeat=2):
	cps = map(lambda dp: tuple(map(sum, zip(p, dp))), deltas)
	if len(tuple(filter(lambda cp: m[cp] == 'o', cps))) % 2:
		print('NO')
		exit()
print('YES')


m = ''
for i in range(int(input())):
	m += input()
if list(m) == list(reversed(m)):
	print('YES')
else:
	print('NO')


n = int(input())
l = []
kk = 0
for i in range(n):
	l.append(list(input()))
for j in range(n):
	if kk == 1:
		break
	for k in range(n):
		ed = 0
		if k > 0:
			if l[j][k - 1] == 'o':
				ed += 1
		if k + 1 <= n - 1:
			if l[j][k + 1] == 'o':
				ed += 1
		if j - 1 >= 0:
			if l[j - 1][k] == 'o':
				ed += 1
		if j + 1 <= n - 1:
			if l[j + 1][k] == 'o':
				ed += 1
		if ed % 2 == 1:
			print('NO')
			kk = 1
			break
		else:
			ed = 0
if kk == 0:
	print('YES')


def isvalid(i, j, n):
	return i >= 0 and j >= 0 and (i < n) and (j < n)
n = int(input())
mat = []
for _ in range(n):
	mat.append(input())
f = 1
for i in range(n):
	for j in range(n):
		c = 0
		if isvalid(i + 1, j, n) and mat[i + 1][j] == 'o':
			c += 1
		if isvalid(i, j + 1, n) and mat[i][j + 1] == 'o':
			c += 1
		if isvalid(i - 1, j, n) and mat[i - 1][j] == 'o':
			c += 1
		if isvalid(i, j - 1, n) and mat[i][j - 1] == 'o':
			c += 1
		if c & 1:
			f = 0
			break
	if not f:
		break
print('YES' if f else 'NO')


n = int(input())
a = []
for i in range(n):
	a.append(input())
res = 'YES'
for i in range(n):
	for j in range(n):
		y = 0
		y += i != 0 and a[i - 1][j] == 'o'
		y += i + 1 != n and a[i + 1][j] == 'o'
		y += j != 0 and a[i][j - 1] == 'o'
		y += j + 1 != n and a[i][j + 1] == 'o'
		if y % 2 == 1:
			res = 'NO'
			break
print(res)


n = int(input())
g = []
for i in range(n):
	g.append(input())
ans = True
for i in range(n):
	for j in range(n):
		count = 0
		if j > 0 and g[i][j - 1] == 'o':
			count += 1
		if j < n - 1 and g[i][j + 1] == 'o':
			count += 1
		if i > 0 and g[i - 1][j] == 'o':
			count += 1
		if i < n - 1 and g[i + 1][j] == 'o':
			count += 1
		if count % 2 != 0:
			ans = False
			break
	if not ans:
		break
if ans:
	print('YES')
else:
	print('NO')


x = int(input())
nums = []
c = 0
for i in range(x):
	nums.append(list(input()))
if len(nums) > 1:
	for i in range(x):
		ans = 0
		for j in range(x):
			if i == 0:
				if nums[i + 1][j] == 'o':
					ans += 1
			elif i == x - 1:
				if nums[i - 1][j] == 'o':
					ans += 1
			else:
				if nums[i + 1][j] == 'o':
					ans += 1
				if nums[i - 1][j] == 'o':
					ans += 1
			if j == 0:
				if nums[i][j + 1] == 'o':
					ans += 1
			elif j == x - 1:
				if nums[i][j - 1] == 'o':
					ans += 1
			else:
				if nums[i][j + 1] == 'o':
					ans += 1
				if nums[i][j - 1] == 'o':
					ans += 1
			if ans % 2 != 0:
				c = 1
				print('NO')
				break
		if c == 1:
			break
if c == 0:
	print('YES')


n = int(input())
field = []
for i in range(n):
	field.append(input())
f = True
steps = ((1, 0), (-1, 0), (0, 1), (0, -1))
for i in range(n):
	for j in range(n):
		cnt = 0
		for step in steps:
			x = i + step[0]
			y = j + step[1]
			if x < 0 or y < 0 or x >= n or (y >= n):
				continue
			if field[x][y] == 'o':
				cnt += 1
		if cnt % 2:
			f = False
print('YES' if f else 'NO')


length = int(input())
matrix = []
for i in range(length):
	matrix.append(list(input()))
if length == 1:
	print('YES')
else:
	alert = False
	for i in range(length):
		for j in range(length):
			count = 0
			if i + 1 < length:
				if matrix[i + 1][j] and matrix[i + 1][j] == 'o':
					count += 1
			if i - 1 >= 0:
				if matrix[i - 1][j] and matrix[i - 1][j] == 'o':
					count += 1
			if j + 1 < length:
				if matrix[i][j + 1] and matrix[i][j + 1] == 'o':
					count += 1
			if j - 1 >= 0:
				if matrix[i][j - 1] and matrix[i][j - 1] == 'o':
					count += 1
			if not alert:
				if count % 2 != 0:
					alert = True
		if alert:
			break
	if not alert:
		print('YES')
	else:
		print('NO')


def checkGrid(A, n):
	nb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
	for i in range(n):
		for j in range(n):
			count = 0
			for p in nb:
				x = i + p[0]
				y = j + p[1]
				if x >= 0 and y >= 0 and (x < n) and (y < n):
					if A[x][y] == 'o':
						count += 1
			if count % 2 == 1:
				return 'NO'
	return 'YES'
n = int(input())
A = []
for i in range(n):
	a = input()
	temp = []
	for c in a:
		temp.append(c)
	A.append(temp)
print(checkGrid(A, n))


a = int(input())
p = []
t1 = []
p.append('x' * (a + 2))
for i in range(a):
	n = 'x'
	n += input()
	p.append(n + 'x')
p.append('x' * (a + 2))
f = 'YES'
h = 0
for i in range(1, a + 1):
	for j in range(1, a + 1):
		t = 0
		if p[i][j - 1] == 'o':
			t += 1
		if p[i][j + 1] == 'o':
			t += 1
		if p[i + 1][j] == 'o':
			t += 1
		if p[i - 1][j] == 'o':
			t += 1
		if t % 2 != 0:
			f = 'NO'
			h = 1
			break
	if h == 1:
		break
print(f)


n = int(input())
a = []
for i in range(n):
	a.append(input())
flag = True
for i in range(n):
	for j in range(n):
		s = 0
		if i + 1 < n and a[i + 1][j] == 'o':
			s += 1
		if j + 1 < n and a[i][j + 1] == 'o':
			s += 1
		if i - 1 >= 0 and a[i - 1][j] == 'o':
			s += 1
		if j - 1 >= 0 and a[i][j - 1] == 'o':
			s += 1
		if s % 2 == 1:
			flag = False
if flag:
	print('YES')
else:
	print('NO')


def prepare(n):
	table = [[0] * n for _ in range(n)]
	for i in range(n):
		line = input()
		for j in range(n):
			if line[j] == 'o':
				if i - 1 >= 0:
					table[i - 1][j] = (table[i - 1][j] + 1) % 2
					if table[i - 1][j] != 0:
						return 'NO'
				if j - 1 >= 0:
					table[i][j - 1] = (table[i][j - 1] + 1) % 2
				if j + 1 < n:
					table[i][j + 1] = (table[i][j + 1] + 1) % 2
				if i + 1 < n:
					table[i + 1][j] = (table[i + 1][j] + 1) % 2
	for j in range(n):
		if table[n - 1][j] != 0:
			return 'NO'
	return 'YES'

def __starting_point():
	n = int(input())
	print(prepare(n))
__starting_point()


import math
import sys

def check(d, n, i, j):
	if i < 0 or i > n - 1 or j < 0 or (j > n - 1):
		return 0
	return d[i][j] == 'o'
n = int(input())
d = []
for i in range(n):
	d.append(input())
for i in range(n):
	for j in range(n):
		r = check(d, n, i - 1, j) + check(d, n, i + 1, j) + check(d, n, i, j - 1) + check(d, n, i, j + 1)
		if r % 2 != 0:
			exit(print('NO'))
print('YES')


n = int(input())
Answer = True
Massif = []
number = 0
for i in range(n):
	Massif.append(list(input()))
for i in range(len(Massif[0])):
	for j in range(len(Massif[0])):
		if i - 1 >= 0:
			if Massif[i - 1][j] == 'o':
				number += 1
		if i + 1 < len(Massif[0]):
			if Massif[i + 1][j] == 'o':
				number += 1
		if j - 1 >= 0:
			if Massif[i][j - 1] == 'o':
				number += 1
		if j + 1 < len(Massif[0]):
			if Massif[i][j + 1] == 'o':
				number += 1
		if number % 2 != 0:
			Answer = False
			break
		else:
			number = 0
	if Answer == False:
		break
if Answer == False:
	print('NO')
else:
	print('YES')


n = int(input())
mat = list()
for i in range(n):
	mat.append(list(input()))
ans = set()
for i in range(n):
	for j in range(n):
		neighbour = [(i, j - 1), (i, j + 1), (i - 1, j), (i + 1, j)]
		s = 0
		for nbr in neighbour:
			if nbr[0] < 0 or nbr[1] < 0 or nbr[1] > n - 1 or (nbr[0] > n - 1):
				continue
			elif mat[nbr[0]][nbr[1]] == 'o':
				s += 1
		ans.add(s)
result = True
for i in ans:
	if i % 2 == 1:
		print('NO')
		result = False
		break
if result:
	print('YES')


def rint():
	return int(input())

def rints():
	return list(map(int, input().split()))
n = rint()
b = [input() for _ in range(n)]
a = True
for y in range(n):
	for x in range(n):
		c = 0
		c += int(x > 0 and b[y][x - 1] == 'o')
		c += int(x < n - 1 and b[y][x + 1] == 'o')
		c += int(y > 0 and b[y - 1][x] == 'o')
		c += int(y < n - 1 and b[y + 1][x] == 'o')
		a = a and c % 2 == 0
print('YES' if a else 'NO')


n = int(input())
s = [None] * n
for i in range(n):
	s[i] = input()
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
for i in range(n):
	for j in range(n):
		cnt = 0
		for k in range(4):
			x = i + dx[k]
			y = j + dy[k]
			if x >= 0 and y >= 0 and (x < n) and (y < n):
				if s[x][y] == 'o':
					cnt += 1
		if cnt % 2 == 1:
			print('NO')
			exit(0)
print('YES')


n = int(input())
grid = []
for i in range(n):
	s = input()
	grid.append(list(s))
flag = 0
for i in range(n):
	c = 0
	for j in range(n):
		if j - 1 >= 0 and grid[i][j - 1] == 'o':
			c += 1
		if i - 1 >= 0 and grid[i - 1][j] == 'o':
			c += 1
		if j + 1 < n and grid[i][j + 1] == 'o':
			c += 1
		if i + 1 < n and grid[i + 1][j] == 'o':
			c += 1
		if c % 2 != 0:
			flag = 1
			break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = ''
for i in range(n):
	s += input()
if n == 1:
	print('YES')
else:
	for i in range(n * n):
		if i == 0:
			c = 0
			if s[i + 1] == 'o':
				c += 1
			if s[i + n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i == n - 1:
			c = 0
			if s[i - 1] == 'o':
				c += 1
			if s[i + n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i // n == 0:
			c = 0
			if s[i - 1] == 'o':
				c += 1
			if s[i + 1] == 'o':
				c += 1
			if s[i + n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i == n * n - n:
			if s[i + 1] == 'o':
				c += 1
			if s[i - n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i == n * n - 1:
			if s[i - 1] == 'o':
				c += 1
			if s[i - n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i // n == n - 1:
			c = 0
			if s[i - 1] == 'o':
				c += 1
			if s[i + 1] == 'o':
				c += 1
			if s[i - n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i % n == 0:
			c = 0
			if s[i + 1] == 'o':
				c += 1
			if s[i - n] == 'o':
				c += 1
			if s[i + n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		elif i % n == n - 1:
			c = 0
			if s[i - 1] == 'o':
				c += 1
			if s[i - n] == 'o':
				c += 1
			if s[i + n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
		else:
			c = 0
			if s[i - 1] == 'o':
				c += 1
			if s[i + 1] == 'o':
				c += 1
			if s[i - n] == 'o':
				c += 1
			if s[i + n] == 'o':
				c += 1
			if c % 2 != 0:
				print('NO')
				break
	else:
		print('YES')


n = int(input())
b = [input() for _ in range(n)]
ans = True
for i in range(n):
	for j in range(n):
		ans &= len([1 for (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)] if 0 <= i + di < n and 0 <= j + dj < n and (b[i + di][j + dj] == 'o')]) % 2 == 0
print('YES' if ans else 'NO')


n = int(input())
a = []
f = int(0)
count = int(0)
for i in range(n):
	a.append(input())
for i in range(n):
	count = int(0)
	for j in range(n):
		if i + 1 < n and a[i + 1][j] == 'o':
			count = count + 1
		if i - 1 >= 0 and a[i - 1][j] == 'o':
			count = count + 1
		if j + 1 < n and a[i][j + 1] == 'o':
			count = count + 1
		if j - 1 >= 0 and a[i][j - 1] == 'o':
			count = count + 1
		if count % 2 != 0:
			f = 1
			break
	if f == 1:
		break
print('YES') if f == 0 else print('NO')


n = int(input())
li = ['0' * (n + 2)]
for j in range(n):
	s = '0' + input().strip() + '0'
	li.append(s)
no_flag = False
cnt = 0
li.append('0' * (n + 2))
temp_li = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for i in range(1, n + 1):
	for j in range(1, n + 1):
		for (a, b) in temp_li:
			if li[a + i][b + j] == 'o':
				cnt += 1
		if cnt % 2 != 0:
			no_flag = True
			break
		cnt = 0
	if no_flag:
		break
if no_flag:
	print('NO')
else:
	print('YES')


n = int(input())
a = []
for i in range(n):
	a.append(input())
for i in range(n):
	for j in range(n):
		l = 0
		if i > 0 and a[i - 1][j] == 'o':
			l += 1
		if i < n - 1 and a[i + 1][j] == 'o':
			l += 1
		if j > 0 and a[i][j - 1] == 'o':
			l += 1
		if j < n - 1 and a[i][j + 1] == 'o':
			l += 1
		if l % 2 != 0:
			print('NO')
			break
	else:
		continue
	break
else:
	print('YES')


def adjacent(M, i, j, n):
	count = 0
	x = [-1, 1, 0, 0]
	y = [0, 0, 1, -1]
	for q in range(4):
		a = x[q] + i
		b = y[q] + j
		if a >= 0 and a < n and (b >= 0) and (b < n):
			if M[a][b] == 'o':
				count += 1
	return count
n = int(input())
M = []
for i in range(n):
	s = input()
	M.append(s)
co = True
for i in range(n):
	for j in range(n):
		if adjacent(M, i, j, n) % 2 != 0:
			co = False
			break
	if not co:
		break
if co:
	print('YES')
else:
	print('NO')


n = int(input())
table = []
for i in range(n):
	row = input()
	table.append(row)
res = 'YES'
countRes = []
for i in range(n):
	row = []
	for j in range(n):
		count = 0
		if i - 1 >= 0:
			if table[i - 1][j] == 'o':
				count += 1
		if i + 1 <= n - 1:
			if table[i + 1][j] == 'o':
				count += 1
		if j - 1 >= 0:
			if table[i][j - 1] == 'o':
				count += 1
		if j + 1 <= n - 1:
			if table[i][j + 1] == 'o':
				count += 1
		row.append(count)
	countRes.append(row)
for row in countRes:
	for x in row:
		if x % 2 == 1:
			res = 'NO'
			break
print(res)


n = int(input())
f = ['x' * (n + 2)]
for i in range(n):
	s = str(input())
	f.append(list('x' + s + 'x'))
f.append('x' * (n + 2))
flag = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		k = [f[i + 1][j], f[i - 1][j], f[i][j + 1], f[i][j - 1]]
		if k.count('o') % 2 != 0:
			flag = False
if flag:
	print('YES')
else:
	print('NO')


num = int(input())
lst = ['0' * (num + 2)]
no_flag = False
for i in range(num):
	string = input()
	lst.append('0' + string + '0')
count = 0
lst.append('0' * (num + 2))
for i in range(1, len(lst) - 1):
	for j in range(1, len(lst) - 1):
		if lst[i - 1][j] == 'o':
			count += 1
		if lst[i + 1][j] == 'o':
			count += 1
		if lst[i][j - 1] == 'o':
			count += 1
		if lst[i][j + 1] == 'o':
			count += 1
		if count % 2 != 0:
			no_flag = True
			break
		count = 0
	if no_flag:
		break
if no_flag:
	print('NO')
else:
	print('YES')


n = int(input())
lis = [0 for i in range(n)]
for i in range(n):
	lis[i] = input()
dic = {}
for i in range(n):
	for j in range(n):
		dic[i, j] = lis[i][j]

def adj(p, q):
	if (p, q) == (0, 0):
		return [(0, 1), (1, 0)]
	elif (p, q) == (0, n - 1):
		return [(0, n - 2), (1, n - 1)]
	elif (p, q) == (n - 1, 0):
		return [(n - 2, 0), (n - 1, 1)]
	elif (p, q) == (n - 1, n - 1):
		return [(n - 1, n - 2), (n - 2, n - 1)]
	elif p == 0:
		return [(0, q - 1), (0, q + 1), (1, q)]
	elif p == n - 1:
		return [(n - 1, q - 1), (n - 1, q + 1), (n - 2, q)]
	elif q == 0:
		return [(p - 1, 0), (p + 1, 0), (p, 1)]
	elif q == n - 1:
		return [(p - 1, n - 1), (p + 1, n - 1), (p, n - 2)]
	else:
		return [(p + 1, q), (p - 1, q), (p, q + 1), (p, q - 1)]

def count(p, q):
	c = 0
	for (a, b) in adj(p, q):
		if dic[a, b] == 'o':
			c += 1
	return c
if n == 1:
	print('YES')
else:
	check = 1
	for i in range(n):
		for j in range(n):
			if count(i, j) % 2 == 1:
				check = 0
	if check == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
rows = []
for x in range(n):
	string = input()
	rows.append(string)
results = 'YES'
for x in range(n):
	for y in range(n):
		a = y + 1
		b = y - 1
		c = x + 1
		d = x - 1
		z = 0
		if a < n:
			if rows[x][a] == 'o':
				z += 1
		if b >= 0:
			if rows[x][b] == 'o':
				z += 1
		if c < n:
			if rows[c][y] == 'o':
				z += 1
		if d >= 0:
			if rows[d][y] == 'o':
				z += 1
		if z % 2 != 0:
			results = 'NO'
			break
print(results)


x = ''
for _ in range(int(input())):
	x += input()
if list(x) == list(reversed(x)):
	print('YES')
else:
	print('NO')


x = int(input())
get = ['x' * (x + 2)] + ['x' + input() + 'x' for _ in range(x)] + ['x' * (x + 2)]
for i in range(1, x + 1):
	for j in range(1, x + 1):
		each = 0
		if get[i - 1][j] == 'o':
			each += 1
		if get[i + 1][j] == 'o':
			each += 1
		if get[i][j - 1] == 'o':
			each += 1
		if get[i][j + 1] == 'o':
			each += 1
		if each % 2 == 1:
			print('NO')
			exit()
print('YES')


n = int(input())
c = [0] * n ** 2
r = lambda : list((c for c in input()))
for _ in range(n):
	if n == 1:
		break
	for (i, x) in enumerate(r()):
		if x != 'o':
			continue
		if i == 0:
			if _ * n + i - n >= 0:
				c[_ * n + i - n] += 1
			if _ * n + i + n < n ** 2:
				c[_ * n + i + n] += 1
			c[_ * n + i + 1] += 1
		elif i == n - 1:
			if _ * n + i - n >= 0:
				c[_ * n + i - n] += 1
			if _ * n + i + n < n ** 2:
				c[_ * n + i + n] += 1
			c[_ * n + i - 1] += 1
		else:
			if _ * n + i - n >= 0:
				c[_ * n + i - n] += 1
			if _ * n + i + n < n ** 2:
				c[_ * n + i + n] += 1
			c[_ * n + i - 1] += 1
			c[_ * n + i + 1] += 1
print(('YES', 'NO')[any((x % 2 for x in c))])


from sys import stdin
A = int(stdin.readline())
B = list()
for k in range(0, A):
	C = stdin.readline()
	B.append(C)
K = 0
for i in range(0, A):
	for j in range(0, A):
		sum = 0
		if i - 1 >= 0:
			if B[i - 1][j] == 'o':
				sum += 1
		if i + 1 <= A - 1:
			if B[i + 1][j] == 'o':
				sum += 1
		if j - 1 >= 0:
			if B[i][j - 1] == 'o':
				sum += 1
		if j + 1 <= A - 1:
			if B[i][j + 1] == 'o':
				sum += 1
		if sum % 2 == 1:
			print('NO')
			K = 1
			break
	if K == 1:
		break
if K == 0:
	print('YES')


n = int(input())
data = [input() for _ in range(n)]
for i in range(n):
	for j in range(n):
		cnt = 0
		if i != 0 and data[i - 1][j] == 'o':
			cnt += 1
		if j != 0 and data[i][j - 1] == 'o':
			cnt += 1
		if i != n - 1 and data[i + 1][j] == 'o':
			cnt += 1
		if j != n - 1 and data[i][j + 1] == 'o':
			cnt += 1
		if cnt % 2 != 0:
			print('NO')
			exit(0)
print('YES')


n = int(input())
x = sum([list(input()) for _ in range(n)], [])
t1 = []
for i in range(n * n):
	t = 0
	if i + 1 < n * n and (i + 1) % n != 0:
		if x[i + 1] == 'o':
			t += 1
	if i + n < n * n:
		if x[i + n] == 'o':
			t += 1
	if i - 1 >= 0 and i % n != 0:
		if x[i - 1] == 'o':
			t += 1
	if i - n >= 0:
		if x[i - n] == 'o':
			t += 1
	t1.append(t)
	if t % 2 == 1:
		print('NO')
		break
else:
	print('YES')


import sys
a = 0
z = int(input())
x = [[i for i in input()] for i in range(z)]
for i in range(z):
	for j in range(z):
		if i != 0:
			if x[i - 1][j] == 'o':
				a += 1
		if i != z - 1:
			if x[i + 1][j] == 'o':
				a += 1
		if j != z - 1:
			if x[i][j + 1] == 'o':
				a += 1
		if j != 0:
			if x[i][j - 1] == 'o':
				a += 1
		if a % 2 != 0:
			print('NO')
			sys.exit(0)
			a = 0
print('YES')


N = int(input())
X = list()
X.append('x' * (N + 2))
for i in range(N):
	X.append('x' + input() + 'x')
	if i == N - 1:
		X.append('x' * (N + 2))
for i in range(1, N + 1):
	for j in range(1, N + 1):
		if [X[i - 1][j], X[i][j - 1], X[i + 1][j], X[i][j + 1]].count('o') % 2 != 0:
			print('NO')
			exit()
print('YES')


n = int(input())
b = []
k = 0
ans = 'YES'
for i in range(n):
	b.append(input())
for i in range(n):
	for j in range(n):
		if j - 1 >= 0:
			if b[i][j - 1] == 'o':
				k += 1
		if j + 1 < n:
			if b[i][j + 1] == 'o':
				k += 1
		if i - 1 >= 0:
			if b[i - 1][j] == 'o':
				k += 1
		if i + 1 < n:
			if b[i + 1][j] == 'o':
				k += 1
		if k % 2 == 1:
			ans = 'NO'
print(ans)


def valid(i, j, n, grid):
	return i >= 0 and j >= 0 and (i <= n - 1) and (j <= n - 1) and (grid[i][j] == 'o')
n = int(input())
grid = [''] * n
for i in range(n):
	grid[i] = str(input())
flag = True
for i in range(n):
	c = 0
	for j in range(n):
		c += valid(i + 1, j, n, grid)
		c += valid(i - 1, j, n, grid)
		c += valid(i, j + 1, n, grid)
		c += valid(i, j - 1, n, grid)
		flag &= c % 2 == 0
print('YES') if flag else print('NO')


n = int(input())
s = []
for i in range(n):
	s.append(input())
for i in range(n):
	for j in range(n):
		os = 0
		for (dx, dy) in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
			x = i + dx
			y = j + dy
			if x < 0 or y < 0 or x >= n or (y >= n):
				continue
			if s[x][y] == 'o':
				os += 1
		if os % 2 != 0:
			print('NO')
			exit()
print('YES')


n = int(input())
nxn = [list(input()) for i in range(n)]
for y in range(n):
	for x in range(n):
		if nxn[y][x] == 'o':
			nxn[y][x] = 1
		else:
			nxn[y][x] = 0
true = 1
if n != 1:
	for y in range(n):
		for x in range(n):
			if y == 0 and x == 0:
				if nxn[1][0] != nxn[0][1]:
					true = 0
					break
			elif y == n - 1 and x == n - 1:
				if nxn[n - 1][n - 2] != nxn[n - 2][n - 1]:
					true = 0
					break
			elif y == n - 1 and x == 0:
				if nxn[n - 2][0] != nxn[n - 1][1]:
					true = 0
					break
			elif y == 0 and x == n - 1:
				if nxn[0][n - 2] != nxn[1][n - 1]:
					true = 0
					break
			elif y == 0:
				if (nxn[0][x - 1] + nxn[1][x] + nxn[0][x + 1]) % 2 != 0:
					true = 0
					break
			elif x == 0:
				if (nxn[y - 1][0] + nxn[y][1] + nxn[y + 1][0]) % 2 != 0:
					true = 0
					break
			elif y == n - 1:
				if (nxn[n - 1][x - 1] + nxn[n - 2][x] + nxn[n - 1][x + 1]) % 2 != 0:
					true = 0
					break
			elif x == n - 1:
				if (nxn[y - 1][n - 1] + nxn[y][n - 2] + nxn[y + 1][n - 1]) % 2 != 0:
					true = 0
					break
			elif (nxn[y - 1][x] + nxn[y][x - 1] + nxn[y + 1][x] + nxn[y][x + 1]) % 2 != 0:
				true = 0
				break
if true == 1:
	print('YES')
else:
	print('NO')


import itertools as ittls
from collections import Counter
import string

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
N = int(input())
A = [[0] * (N + 2) for _ in range(N + 2)]
for i in range(1, N + 1):
	s = input()
	for (j, v) in enumerate(s):
		A[i][j + 1] = int(v == 'o')
for i in range(1, N + 1):
	for j in range(1, N + 1):
		s = A[i - 1][j - 0] + A[i + 1][j + 0] + A[i - 0][j - 1] + A[i + 0][j + 1]
		if s & 1:
			print('NO')
			quit()
print('YES')


__author__ = 'Глеб'
import sys
n = int(input())
desk = [[0] * (n + 10) for j in range(n + 10)]
for i in range(n):
	str = input()
	for j in range(n):
		if str[j] == 'x':
			desk[i][j] = 0
		else:
			desk[i][j] = 1
for i in range(n):
	for j in range(n):
		if (desk[i][j + 1] + desk[i][j - 1] + desk[i + 1][j] + desk[i - 1][j]) % 2 != 0:
			print('NO')
			return
print('YES')


n = int(input())
b = [input() for i in range(n)]
f = True
for i in range(n):
	for j in range(n):
		c = 0
		if i - 1 > -1 and b[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and b[i + 1][j] == 'o':
			c += 1
		if j - 1 > -1 and b[i][j - 1] == 'o':
			c += 1
		if j + 1 < n and b[i][j + 1] == 'o':
			c += 1
		if c % 2:
			f = False
			break
	if not f:
		break
print('YES' if f else 'NO')


n = int(input())
m = []
for _ in range(n):
	m.append(input())
v = [[0, 1], [0, -1], [1, 0], [-1, 0]]
ans = 'YES'
for i in range(n):
	for j in range(n):
		cnt = 0
		for (x, y) in v:
			if i + x in range(n) and j + y in range(n) and (m[i + x][j + y] == 'o'):
				cnt += 1
		if cnt % 2 != 0:
			ans = 'NO'
print(ans)


n = int(input())
grid = []
for i in range(n):
	grid.append(list(input()))
for x in range(n):
	count = 0
	for y in range(n):
		if x > 0 and grid[x - 1][y] == 'o':
			count += 1
		if x < n - 1 and grid[x + 1][y] == 'o':
			count += 1
		if y > 0 and grid[x][y - 1] == 'o':
			count += 1
		if y < n - 1 and grid[x][y + 1] == 'o':
			count += 1
		if count % 2 != 0:
			print('NO')
			exit()
print('YES')


import sys
n = int(input())
cnt = [[0 for x in range(107)] for y in range(107)]
for i in range(1, n + 1):
	s = input()
	for j in range(1, n + 1):
		cnt[i][j] = s[j - 1] == 'o'
for i in range(1, n + 1):
	for j in range(1, n + 1):
		num = cnt[i][j + 1] + cnt[i][j - 1] + cnt[i + 1][j] + cnt[i - 1][j]
		if num % 2:
			print('NO')
			exit()
print('YES')


n = int(input())
s = ''
for i in range(n):
	s1 = input()
	s += s1
if s == s[::-1]:
	print('YES')
else:
	print('NO')


n = int(input())
grid = [input() for _ in range(n)]
works = True
moves = [(0, 1), (1, 0), (0, -1), (-1, 0)]
for i in range(n):
	for j in range(n):
		around = 0
		for (dx, dy) in moves:
			(nx, ny) = (i + dx, j + dy)
			if 0 <= nx < n and 0 <= ny < n:
				around += grid[nx][ny] == 'o'
		if around % 2 == 1:
			works = False
print('YES' if works else 'NO')


n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
for i in range(n):
	c = 0
	for j in range(n):
		if i - 1 >= 0 and j >= 0 and (j < n) and (a[i - 1][j] == 'o'):
			c += 1
		if i + 1 < n and j >= 0 and (j < n) and (a[i + 1][j] == 'o'):
			c += 1
		if i >= 0 and i < n and (j - 1 >= 0) and (a[i][j - 1] == 'o'):
			c += 1
		if i >= 0 and i < n and (j + 1 < n) and (a[i][j + 1] == 'o'):
			c += 1
		if c % 2 != 0:
			print('NO')
			exit(0)
print('YES')


total_lines = int(input())
data = [input() for _ in range(total_lines)]

def even_os_around(data, i, j, total):
	count = 0
	if i > 0:
		count += data[i - 1][j] == 'o'
	if i < total - 1:
		count += data[i + 1][j] == 'o'
	if j > 0:
		count += data[i][j - 1] == 'o'
	if j < total - 1:
		count += data[i][j + 1] == 'o'
	return count % 2 == 0
result = all((even_os_around(data, i, j, total_lines) for i in range(total_lines) for j in range(total_lines)))
print('YES' if result else 'NO')


n = int(input())
c = [[] for i in range(n + 2)]
for i in range(n + 2):
	for _ in range(n + 2):
		c[i].append(0)
for i in range(1, n + 1):
	for (k, j) in enumerate(input(), 1):
		if j == 'o':
			c[i][k - 1] += 1
			c[i][k + 1] += 1
			c[i + 1][k] += 1
			c[i - 1][k] += 1
o = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if c[i][j] % 2 != 0:
			o = False
			break
if o:
	print('YES')
else:
	print('NO')


def check():
	for i in range(n):
		for j in range(n):
			c = 0
			if j < n - 1 and m[i][j + 1] == 'o':
				c += 1
			if j > 0 and m[i][j - 1] == 'o':
				c += 1
			if i < n - 1 and m[i + 1][j] == 'o':
				c += 1
			if i > 0 and m[i - 1][j] == 'o':
				c += 1
			if c == 1 or c == 3:
				return 'NO'
	return 'YES'
m = []
n = int(input())
for i in range(n):
	m.append(input())
print(check())


n = int(input())
(a, s, k) = ([], '', '')
for i in range(n):
	f = input()
	a.append(f)
for i in a:
	s = s + i
for i in range(len(s) - 1, -1, -1):
	k = k + s[i]
if s == k:
	print('YES')
else:
	print('NO')


n = int(input())
m = list()
for i in range(n):
	m.append(input())
for i in range(n):
	for j in range(n):
		k = 0
		if i > 0 and m[i - 1][j] == 'o':
			k += 1
		if i < n - 1 and m[i + 1][j] == 'o':
			k += 1
		if j > 0 and m[i][j - 1] == 'o':
			k += 1
		if j < n - 1 and m[i][j + 1] == 'o':
			k += 1
		if k % 2:
			print('NO')
			return
print('YES')


n = int(input())
ar = []
for i in range(n):
	lis = input()
	ar.append(lis)
f = 0
for i in range(n):
	for j in range(n):
		c = 0
		if i - 1 >= 0 and ar[i - 1][j] == 'o':
			c += 1
		if j - 1 >= 0 and ar[i][j - 1] == 'o':
			c += 1
		if i + 1 < n and ar[i + 1][j] == 'o':
			c += 1
		if j + 1 < n and ar[i][j + 1] == 'o':
			c += 1
		if c != 0 and c % 2 != 0:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print('NO')
else:
	print('YES')


n = int(input(''))
a = [[x for x in input()] for j in range(n)]
flag = 0
if n > 1:
	for i in range(n):
		for j in range(n):
			count = 0
			if a[i][j]:
				k1 = j + 1 if j + 1 < n else j
				k2 = j if j - 1 < 0 else j - 1
				k3 = i + 1 if i + 1 < n else i
				k4 = i if i - 1 < 0 else i - 1
				if k1 != j and k2 != j:
					if a[i][k1] == 'o':
						count += 1
					if a[i][k2] == 'o':
						count += 1
				elif a[i][k1 if k2 == j else k2] == 'o':
					count += 1
				if k3 != i and k4 != i:
					if a[k3][j] == 'o':
						count += 1
					if a[k4][j] == 'o':
						count += 1
				elif a[k3 if k4 == i else k4][j] == 'o':
					count += 1
			if count % 2 != 0:
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')
else:
	print('YES')


n = int(input())
mat = []
for i in range(n):
	mat.append(list(input()))
for i in range(n):
	for j in range(n):
		count = 0
		if i > 0 and mat[i - 1][j] == 'o':
			count += 1
		if j > 0 and mat[i][j - 1] == 'o':
			count += 1
		if i < n - 1 and mat[i + 1][j] == 'o':
			count += 1
		if j < n - 1 and mat[i][j + 1] == 'o':
			count += 1
		if count & 1:
			print('NO')
			exit()
print('YES')


def solve(board):
	max_height = len(board)
	max_width = len(board[0])
	for (i, row) in enumerate(board):
		for (j, cell) in enumerate(row):
			count = 0
			for o in range(i - 1, i + 2):
				for p in range(j - 1, j + 2):
					if o < 0 or o >= max_height:
						continue
					if p < 0 or p >= max_width:
						continue
					if o == i and p == j:
						continue
					if abs(i - o) + abs(j - p) == 1 and board[o][p] == 'o':
						count += 1
			if count & 1:
				return 'NO'
	return 'YES'
n = int(input())
b = []
for i in range(n):
	b.append(input())
print(solve(b))


n = int(input())
s = [[]] * (n + 2)
s[0] = ['x'] * (n + 2)
for i in range(1, n + 1):
	s[i] = ['x'] + list(input()) + ['x']
s[n + 1] = ['x'] * (n + 2)
f = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		c = 0
		if s[i - 1][j] == 'o':
			c += 1
		if s[i][j - 1] == 'o':
			c += 1
		if s[i + 1][j] == 'o':
			c += 1
		if s[i][j + 1] == 'o':
			c += 1
		if c % 2 != 0:
			f = False
			break
if f:
	print('YES')
else:
	print('NO')


import os
import sys
from bisect import bisect_left
from io import BytesIO, IOBase
BUFSIZE = 8192

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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def solve():
	n = readint()
	mat = [readstr() for _ in range(n)]
	if n == 1:
		print('YES')
		return
	for i in range(n):
		for j in range(n):
			cnt = 0
			if i == 0:
				if j == 0:
					if mat[i][j + 1] == 'o':
						cnt += 1
					if mat[i + 1][j] == 'o':
						cnt += 1
				elif j == n - 1:
					if mat[i][j - 1] == 'o':
						cnt += 1
					if mat[i + 1][j] == 'o':
						cnt += 1
				else:
					if mat[i][j - 1] == 'o':
						cnt += 1
					if mat[i][j + 1] == 'o':
						cnt += 1
					if mat[i + 1][j] == 'o':
						cnt += 1
				if cnt & 1:
					print('NO')
					return
			elif i == n - 1:
				if j == 0:
					if mat[i][j + 1] == 'o':
						cnt += 1
					if mat[i - 1][j] == 'o':
						cnt += 1
				elif j == n - 1:
					if mat[i][j - 1] == 'o':
						cnt += 1
					if mat[i - 1][j] == 'o':
						cnt += 1
				else:
					if mat[i][j - 1] == 'o':
						cnt += 1
					if mat[i][j + 1] == 'o':
						cnt += 1
					if mat[i - 1][j] == 'o':
						cnt += 1
				if cnt & 1:
					print('NO')
					return
			else:
				if j == 0:
					if mat[i - 1][j] == 'o':
						cnt += 1
					if mat[i + 1][j] == 'o':
						cnt += 1
					if mat[i][j + 1] == 'o':
						cnt += 1
				elif j == n - 1:
					if mat[i - 1][j] == 'o':
						cnt += 1
					if mat[i + 1][j] == 'o':
						cnt += 1
					if mat[i][j - 1] == 'o':
						cnt += 1
				else:
					if mat[i][j - 1] == 'o':
						cnt += 1
					if mat[i][j + 1] == 'o':
						cnt += 1
					if mat[i - 1][j] == 'o':
						cnt += 1
					if mat[i + 1][j] == 'o':
						cnt += 1
				if cnt & 1:
					print('NO')
					return
	print('YES')

def main():
	t = 1
	for _ in range(t):
		solve()
main()


def isEvenAdj(*line):
	width = len(line)
	data = line
	for i in range(width):
		for j in range(width):
			is_even = True
			if j + 1 < width and data[i][j + 1] == 'o':
				is_even = not is_even
			if i + 1 < width and data[i + 1][j] == 'o':
				is_even = not is_even
			if j - 1 >= 0 and data[i][j - 1] == 'o':
				is_even = not is_even
			if i - 1 >= 0 and data[i - 1][j] == 'o':
				is_even = not is_even
			if not is_even:
				return False
	return True

def main():
	width = input()
	line = []
	for i in range(int(width)):
		line.append(input())
	print('YES' if isEvenAdj(*line) else 'NO')
main()


n = int(input())
matrix = []
for i in range(0, n):
	line = input()
	line = line.strip()
	line = line.lower()
	line = list(line)
	matrix.append(line)
flag = 0
for i in range(0, n):
	for j in range(0, n):
		zero = 0
		if i > 0 and matrix[i - 1][j] == 'o':
			zero = zero + 1
		if j > 0 and matrix[i][j - 1] == 'o':
			zero = zero + 1
		if i < n - 1 and matrix[i + 1][j] == 'o':
			zero = zero + 1
		if j < n - 1 and matrix[i][j + 1] == 'o':
			zero = zero + 1
		if zero % 2 != 0:
			flag = 1
			break
	if flag == 1:
		break
if flag == 1:
	print('NO')
else:
	print('YES')


s = lambda x: x == 'x'
n = int(input())
t = [list(map(s, input())) + [1] for i in range(n)] + [[1] * (n + 1)]
for i in range(n):
	for j in range(n):
		if t[i - 1][j] + t[i + 1][j] + t[i][j - 1] + t[i][j + 1] & 1:
			print('NO')
			exit(0)
print('YES')


import sys

def data():
	return sys.stdin.readline().strip()

def sp():
	return map(int, data().split())

def l():
	return list(sp())
n = int(data())
res = []
for i in range(n):
	res.append(list(data()))
even = 0
flag = True
for i in range(n):
	for j in range(n):
		if i - 1 >= 0 and res[i - 1][j] == 'o':
			even += 1
		if i + 1 < n and res[i + 1][j] == 'o':
			even += 1
		if j - 1 >= 0 and res[i][j - 1] == 'o':
			even += 1
		if j + 1 < n and res[i][j + 1] == 'o':
			even += 1
		if even % 2 == 1:
			flag = False
if flag:
	print('YES')
else:
	print('NO')


def get_result(board):
	for row_num in range(n):
		for col_num in range(n):
			if not check(board, row_num, col_num):
				return 'NO'
	return 'YES'

def check(board, row_num, col_num):
	count = 0
	if row_num > 0 and board[row_num - 1][col_num] == 'o':
		count += 1
	if row_num < len(board) - 1 and board[row_num + 1][col_num] == 'o':
		count += 1
	if col_num > 0 and board[row_num][col_num - 1] == 'o':
		count += 1
	if col_num < len(board) - 1 and board[row_num][col_num + 1] == 'o':
		count += 1
	return count % 2 == 0
n = int(input())
board = [input() for _ in range(n)]
print(get_result(board))


def solve():
	n = int(input())
	mx = []
	for _ in range(n):
		mx.append(input())
	for i in range(n):
		for j in range(n):
			ans = 0
			if j != n - 1 and mx[i][j + 1] == 'o':
				ans += 1
			if j != 0 and mx[i][j - 1] == 'o':
				ans += 1
			if i != n - 1 and mx[i + 1][j] == 'o':
				ans += 1
			if i != 0 and mx[i - 1][j] == 'o':
				ans += 1
			if ans & 1:
				return 'NO'
	return 'YES'
print(solve())


n = int(input())
checker = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
	string = input()
	for j in range(n):
		checker[i][j] = string[j]
for i in range(n):
	for j in range(n):
		count = 0
		if i - 1 >= 0 and checker[i - 1][j] == 'o':
			count += 1
		if i + 1 < n and checker[i + 1][j] == 'o':
			count += 1
		if j - 1 >= 0 and checker[i][j - 1] == 'o':
			count += 1
		if j + 1 < n and checker[i][j + 1] == 'o':
			count += 1
		if count % 2 == 1:
			print('NO')
			exit()
print('YES')


import sys, collections, math, itertools, random
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
n = int(input())
s = ''
for tt in range(n):
	temp = input()
	s += temp
if list(s) == list(reversed(s)):
	print('YES')
else:
	print('NO')


n = int(input())
a = []
for x in range(n):
	a.append(input())
for x in range(n):
	for y in range(n):
		count = 0
		m = x - 1
		if m >= 0 and a[m][y] == 'o':
			count += 1
		m = x + 1
		if m <= n - 1 and a[m][y] == 'o':
			count += 1
		m = y - 1
		if m >= 0 and a[x][m] == 'o':
			count += 1
		m = y + 1
		if m <= n - 1 and a[x][m] == 'o':
			count += 1
		if count % 2 != 0:
			print('NO')
			exit(0)
print('YES')


table = []
actions = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def go(pos, diff):
	return (pos[0] + diff[0], pos[1] + diff[1])

def check(pos, n):
	return pos[0] >= 0 and pos[0] < n and (pos[1] >= 0) and (pos[1] < n)

def pt(pos):
	return pos[1] + pos[0] * n

def is_even(table, pos):
	global actions
	count = 0
	for action in actions:
		tgt = go(pos, action)
		if check(tgt, n):
			if table[pt(tgt)] == 'o':
				count += 1
	return count % 2 == 0
n = int(input())
for x in range(n):
	table += input()
for i in range(n):
	for j in range(n):
		if not is_even(table, (i, j)):
			print('NO')
			quit()
print('YES')


def f(x):
	return 1 if x == 'x' else 0
n = int(input())
t = [list(map(f, input())) + [1] for i in range(n)] + [[1] * (n + 1)]
for i in range(n):
	for j in range(n):
		if t[i - 1][j] + t[i + 1][j] + t[i][j + 1] + t[i][j - 1] & 1:
			print('NO')
			exit(0)
print('YES')


def function(i, j):
	if (i >= 0 and i < n) and (j >= 0 and j < n):
		return True
	else:
		return False
n = int(input().strip())
arr = [[str(i) for i in input().strip()] for j in range(n)]
flag = 1
for i in range(n):
	for j in range(n):
		count = 0
		if function(i, j - 1) == True:
			if arr[i][j - 1] == 'o':
				count += 1
		if function(i, j + 1) == True:
			if arr[i][j + 1] == 'o':
				count += 1
		if function(i - 1, j) == True:
			if arr[i - 1][j] == 'o':
				count += 1
		if function(i + 1, j) == True:
			if arr[i + 1][j] == 'o':
				count += 1
		if count % 2 != 0:
			flag = 0
			break
	if flag == 0:
		print('NO')
		break
else:
	print('YES')


n = int(input())
mas = [[0] * (n + 1) for x in range(n + 1)]
for i in range(n):
	j = 0
	for s in input():
		if s == 'o':
			mas[i + 1][j] += 1
			mas[i - 1][j] += 1
			mas[i][j + 1] += 1
			mas[i][j - 1] += 1
		j += 1
res = 1
for i in range(n):
	for j in range(n):
		if mas[i][j] % 2 != 0:
			res = 0
print('YES') if res else print('NO')


n = int(input())
Board = []
Even = True
for i in range(n):
	Board.append(input())
for i in range(n):
	for j in range(n):
		S = 0
		if i != n - 1:
			if Board[i + 1][j] == 'o':
				S += 1
		if i != 0:
			if Board[i - 1][j] == 'o':
				S += 1
		if j != n - 1:
			if Board[i][j + 1] == 'o':
				S += 1
		if j != 0:
			if Board[i][j - 1] == 'o':
				S += 1
		if S % 2 != 0:
			Even = False
			break
if Even:
	print('YES')
else:
	print('NO')


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007
n = vary(1)
arr = [[-1 for i in range(n + 2)] for j in range(n + 2)]
for i in range(1, n + 1):
	s = input()
	st = list(s)
	for j in range(1, n + 1):
		arr[i][j] = st[j - 1]
flag = 0
for i in range(1, n + 1):
	if flag == -1:
		break
	for j in range(1, n + 1):
		count = 0
		if arr[i][j + 1] == 'o':
			count += 1
		if arr[i][j - 1] == 'o':
			count += 1
		if arr[i + 1][j] == 'o':
			count += 1
		if arr[i - 1][j] == 'o':
			count += 1
		if count % 2 != 0:
			flag = -1
			print('NO')
			break
else:
	print('YES')


def check(i, j, mat):
	size = len(mat) - 1
	cant = 0
	a = j - 1
	if a >= 0:
		if mat[i][a] == 'o':
			cant += 1
	a = j + 1
	if a <= size:
		if mat[i][a] == 'o':
			cant += 1
	a = i - 1
	if a >= 0:
		if mat[a][j] == 'o':
			cant += 1
	a = i + 1
	if a <= size:
		if mat[a][j] == 'o':
			cant += 1
	return cant

def main():
	n = int(input())
	mat = [['' for x in range(n)] for y in range(n)]
	mat = []
	for i in range(0, n):
		s = str(input())
		mat.append(list(s))
	size = len(mat)
	for i in range(size):
		for j in range(size):
			cant = check(i, j, mat)
			if cant % 2 != 0:
				print('NO')
				return
	print('YES')
	return
main()


n = int(input())
a = []
k = 0
a.append([0 for i in range(n + 2)])
for i in range(n):
	b = list(input())
	b = [0] + b
	b.append(0)
	a.append(b)
a.append([0 for i in range(n + 2)])
for i in range(1, len(a) - 1):
	for j in range(1, len(a) - 1):
		if a[i][j + 1] == 'o':
			k += 1
		if a[i][j - 1] == 'o':
			k += 1
		if a[i - 1][j] == 'o':
			k += 1
		if a[i + 1][j] == 'o':
			k += 1
		if k % 2 != 0:
			print('NO')
			exit()
		else:
			k = 0
print('YES')


n = int(input())
row = []
for i in range(n):
	row.append(input())
left = row[:n // 2 + 1]
right = row[n // 2:]
right = right[::-1]
check = True
for i in range(n // 2):
	if right[i][::-1] != left[i]:
		check = False
		break
print('YES' if check else 'NO')


q = ''
exec('q+=input();' * int(input()))
print('YES' if q == q[::-1] else 'NO')


n = int(input())
board = [[0] * (n + 2)]
for i in range(n):
	board += [[0] + [0 if x == 'x' else 1 for x in input()] + [0]]
board += [[0] * (n + 2)]
yn = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		yn = yn and (board[i - 1][j] + board[i + 1][j] + board[i][j - 1] + board[i][j + 1]) % 2 == 0
print('YES' if yn else 'NO')


class CodeforcesTask462ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.board = []

	def read_input(self):
		self.n = int(input())
		for x in range(self.n):
			self.board.append(input())

	def process_task(self):
		adj = [[0] * self.n for x in range(self.n)]
		pos = True
		for x in range(self.n):
			for y in range(self.n):
				if x:
					adj[x][y] += 1 if self.board[x - 1][y] == 'o' else 0
				if y:
					adj[x][y] += 1 if self.board[x][y - 1] == 'o' else 0
				if x < self.n - 1:
					adj[x][y] += 1 if self.board[x + 1][y] == 'o' else 0
				if y < self.n - 1:
					adj[x][y] += 1 if self.board[x][y + 1] == 'o' else 0
				if adj[x][y] % 2:
					pos = False
					break
			if not pos:
				break
		self.result = 'YES' if pos else 'NO'

	def get_result(self):
		return self.result
Solution = CodeforcesTask462ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


r = int(input())
list1 = []
list2 = []
for i in range(r):
	k = list(map(str, input().split()))
	list1.append(k)
for i in range(len(list1)):
	list2.append([])
	for j in list1[i]:
		for k in range(len(j)):
			list2[i].append(j[k])
if r == 1:
	print('YES')
set = {'l'}
if r != 1:
	for i in range(r):
		for j in range(r):
			count = 0
			if i < r - 1 and j < r - 1 and (i != 0) and (j != 0):
				if list2[i][j + 1] == 'o':
					count += 1
				if list2[i - 1][j] == 'o':
					count += 1
				if list2[i][j - 1] == 'o':
					count += 1
				if list2[i + 1][j] == 'o':
					count += 1
			if i == 0 and j != r - 1 and (j != 0):
				if list2[i][j + 1] == 'o':
					count += 1
				if list2[i + 1][j] == 'o':
					count += 1
				if list2[i][j - 1] == 'o':
					count += 1
			if i == r - 1 and j != r - 1 and (j != 0):
				if list2[i - 1][j] == 'o':
					count += 1
				if list2[i][j + 1] == 'o':
					count += 1
				if list2[i][j - 1] == 'o':
					count += 1
			if j == 0 and i != r - 1 and (i != 0):
				if list2[j][i + 1] == 'o':
					count += 1
				if list2[j + 1][i] == 'o':
					count += 1
				if list2[j][i - 1] == 'o':
					count += 1
			if j == r - 1 and i != r - 1 and (i != 0):
				if list2[j - 1][i] == 'o':
					count += 1
				if list2[j][i + 1] == 'o':
					count += 1
				if list2[j][i - 1] == 'o':
					count += 1
			if i == 0 and j == 0:
				if list2[i + 1][j] == 'o':
					count += 1
				if list2[i][j + 1] == 'o':
					count += 1
			if i == 0 and j == r - 1:
				if list2[i][j - 1] == 'o':
					count += 1
				if list2[i + 1][j] == 'o':
					count += 1
			if i == r - 1 and j == 0:
				if list2[i][j + 1] == 'o':
					count += 1
				if list2[i - 1][j] == 'o':
					count += 1
			if i == r - 1 and j == r - 1:
				if list2[i][j - 1] == 'o':
					count += 1
				if list2[i - 1][j] == 'o':
					count += 1
			if count % 2 == 0:
				set.add('yes')
			else:
				set.add('no')
				set.add((i, j))
	if 'yes' in set:
		if 'no' in set:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


N = int(input())
m = [input() for i in range(N)]
(dx, dy) = ([0, 0, 1, -1], [1, -1, 0, 0])
for x in range(N):
	for y in range(N):
		cnt = 0
		for i in range(4):
			(tx, ty) = (x + dx[i], y + dy[i])
			if 0 <= tx < N and 0 <= ty < N and (m[ty][tx] == 'o'):
				cnt += 1
		if cnt % 2:
			print('NO')
			exit()
print('YES')


n = int(input())
p = []
zoj = True
for i in range(n):
	s = input()
	p.append(s)
for i in range(n):
	for j in range(n):
		cnt = 0
		if i > 0:
			if p[i - 1][j] == 'o':
				cnt += 1
		if j > 0:
			if p[i][j - 1] == 'o':
				cnt += 1
		if i < n - 1:
			if p[i + 1][j] == 'o':
				cnt += 1
		if j < n - 1:
			if p[i][j + 1] == 'o':
				cnt += 1
		if cnt % 2 == 1:
			zoj = False
			break
if zoj:
	print('YES')
else:
	print('NO')


n = int(input())
l = []
for _ in range(n):
	l.append(input())
ans = True
for i in range(n):
	for j in range(n):
		c = 0
		if l[i][j - 1] == 'o' and j - 1 >= 0:
			c += 1
		try:
			if l[i][j + 1] == 'o':
				c += 1
		except:
			pass
		try:
			if l[i + 1][j] == 'o':
				c += 1
		except:
			pass
		try:
			if l[i - 1][j] == 'o' and i - 1 >= 0:
				c += 1
		except:
			pass
		if c % 2 != 0:
			print('NO')
			ans = False
			break
	if not ans:
		break
else:
	print('YES')


def arr_inp(n):
	return [input() for x in range(n)]

def get_col(arr, i):
	return ''.join([row[i] for row in arr])
n = int(input())
s = arr_inp(n)
for i in range(n):
	for j in range(n):
		sum = 0
		if i < n - 1 and s[i + 1][j] == 'o':
			sum += 1
		if i > 0 and s[i - 1][j] == 'o':
			sum += 1
		if j > 0 and s[i][j - 1] == 'o':
			sum += 1
		if j < n - 1 and s[i][j + 1] == 'o':
			sum += 1
		if sum % 2 != 0:
			exit(print('NO'))
print('YES')


n = int(input())
l = [list(input()) for i in range(n)]
t = 0
a = 'YES'
if n == 1:
	print(a)
else:
	for r in range(n):
		for c in range(n):
			if r == 0 and c == 0:
				if l[r + 1][c] == 'o':
					t += 1
				if l[r][c + 1] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r == 0 and c != n - 1:
				t = 0
				if l[r + 1][c] == 'o':
					t += 1
				if l[r][c - 1] == 'o':
					t += 1
				if l[r][c + 1] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r == 0 and c == n - 1:
				t = 0
				if l[r + 1][c] == 'o':
					t += 1
				if l[r][c - 1] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r != n - 1 and c == 0:
				t = 0
				if l[r + 1][c] == 'o':
					t += 1
				if l[r][c + 1] == 'o':
					t += 1
				if l[r - 1][c] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r != n - 1 and c != n - 1:
				t = 0
				if l[r + 1][c] == 'o':
					t += 1
				if l[r][c + 1] == 'o':
					t += 1
				if l[r - 1][c] == 'o':
					t += 1
				if l[r][c - 1] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r != n - 1 and c == n - 1:
				t = 0
				if l[r + 1][c] == 'o':
					t += 1
				if l[r][c - 1] == 'o':
					t += 1
				if l[r - 1][c] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r == n - 1 and c == 0:
				t = 0
				if l[r][c + 1] == 'o':
					t += 1
				if l[r - 1][c] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r == n - 1 and c != n - 1:
				t = 0
				if l[r][c + 1] == 'o':
					t += 1
				if l[r - 1][c] == 'o':
					t += 1
				if l[r][c - 1] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
			elif r == n - 1 and c == n - 1:
				t = 0
				if l[r][c - 1] == 'o':
					t += 1
				if l[r - 1][c] == 'o':
					t += 1
				if t % 2 != 0:
					a = 'NO'
					break
	print(a)


n = int(input())
board = []
for line in range(0, n):
	board.append(input())
yn = True
for i in range(0, n):
	for j in range(0, n):
		count = 0
		if i - 1 >= 0:
			if board[i - 1][j] == 'o':
				count = count + 1
		if i + 1 < n:
			if board[i + 1][j] == 'o':
				count = count + 1
		if j - 1 >= 0:
			if board[i][j - 1] == 'o':
				count = count + 1
		if j + 1 < n:
			if board[i][j + 1] == 'o':
				count = count + 1
		if count % 2 != 0:
			yn = False
if yn:
	print('YES')
else:
	print('NO')


n = int(input())
l = [input() for i in range(n)]
s = [[0] * n for i in range(n)]
for i in range(n):
	for (j, element) in enumerate(l[i]):
		if element == 'o':
			if j != n - 1:
				s[i][j + 1] = s[i][j + 1] + 1
			if j != 0:
				s[i][j - 1] += 1
			if i != n - 1:
				s[i + 1][j] += 1
			if i != 0:
				s[i - 1][j] += 1
result = 'YES'
for elements in s:
	for element in elements:
		if element % 2:
			result = 'NO'
			break
print(result)


f = True
board = []
n = int(input())
for i in range(n):
	arr = input()
	board.append(arr)
	k = 0
for i in range(n):
	c = 0
	for j in range(len(board)):
		if i - 1 >= 0 and board[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and board[i + 1][j] == 'o':
			c += 1
		if j - 1 >= 0 and board[i][j - 1] == 'o':
			c += 1
		if j + 1 < n and board[i][j + 1] == 'o':
			c += 1
		if c % 2 == 1:
			f = False
if f:
	print('YES')
else:
	print('NO')


n = int(input())
face = list()
for i in range(n):
	line = str(input())
	temp_list = list()
	for j in range(n):
		if line[j] == 'o':
			temp_list.append(1)
		else:
			temp_list.append(0)
	face.append(temp_list)
flag = False
for i in range(n):
	for j in range(n):
		temp_sum = 0
		if i > 0:
			temp_sum += face[i - 1][j]
		if i < n - 1:
			temp_sum += face[i + 1][j]
		if j > 0:
			temp_sum += face[i][j - 1]
		if j < n - 1:
			temp_sum += face[i][j + 1]
		if temp_sum % 2 == 1:
			flag = True
			break
	if flag:
		break
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
s = ''
for x in range(n):
	s += input()
if list(s) == list(reversed(s)):
	print('YES')
else:
	print('NO')


n = int(input())
s = []
adjacent = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
	s.append(input())
for i in range(n):
	for j in range(n):
		if s[i][j] == 'o':
			if i + 1 < n:
				adjacent[i + 1][j] += 1
			if i - 1 >= 0:
				adjacent[i - 1][j] += 1
			if j + 1 < n:
				adjacent[i][j + 1] += 1
			if j - 1 >= 0:
				adjacent[i][j - 1] += 1
for i in range(n):
	for j in range(n):
		if adjacent[i][j] > 0 and adjacent[i][j] & 1 == 1:
			print('NO')
			break
	else:
		continue
	break
else:
	print('YES')


def func():
	n = int(input())
	board = []
	for row in range(0, n):
		board.append([x for x in input()])
	cont = 0
	for row in range(0, n):
		for col in range(0, n):
			cont = 0
			if col + 1 < n and board[row][col + 1] == 'o':
				cont += 1
			if col - 1 >= 0 and board[row][col - 1] == 'o':
				cont += 1
			if row + 1 < n and board[row + 1][col] == 'o':
				cont += 1
			if row - 1 >= 0 and board[row - 1][col] == 'o':
				cont += 1
			if cont % 2 != 0:
				return 'NO'
	return 'YES'
print(func())


def nbrs(a, i, j):
	ctr = 0
	if a[i - 1][j] == 'o':
		ctr += 1
	if a[i + 1][j] == 'o':
		ctr += 1
	if a[i][j - 1] == 'o':
		ctr += 1
	if a[i][j + 1] == 'o':
		ctr += 1
	return ctr
flag = True
n = int(input())
a = [0] * (n + 2)
a[0] = 'x' * (n + 2)
a[n + 1] = 'x' * (n + 2)
for i in range(1, n + 1):
	a[i] = 'x' + input().split()[0] + 'x'
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if nbrs(a, i, j) % 2 == 1:
			flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
a = []
k = 'l'
m = ['l'] * (n + 2)
b = [m]
for i in range(0, n):
	a = list(input())
	a.append(k)
	a.insert(0, k)
	b.append(a)
b.append(m)
k = 1
for i in range(1, n + 1):
	c = 0
	for j in range(1, n + 1):
		if b[j - 1][i] == 'o':
			c = c + 1
		if b[j + 1][i] == 'o':
			c = c + 1
		if b[j][i - 1] == 'o':
			c = c + 1
		if b[j][i + 1] == 'o':
			c = c + 1
		if c % 2 != 0:
			k = 0
			break
if k == 1:
	print('YES')
else:
	print('NO')


s = ''
n = int(input())
for _ in range(n):
	s += input()
print('YES') if s == s[::-1] else print('NO')


n = int(input())
m = []
rip = False

def check(i, j):
	count = 0
	if i > 0 and m[i - 1][j] == 'o':
		count += 1
	if i < n - 1 and m[i + 1][j] == 'o':
		count += 1
	if j > 0 and m[i][j - 1] == 'o':
		count += 1
	if j < n - 1 and m[i][j + 1] == 'o':
		count += 1
	return count % 2
for i in range(n):
	s = input()
	m.append(s)
for i in range(n):
	for j in range(n):
		if check(i, j) != 0:
			rip = True
			break
if rip:
	print('NO')
else:
	print('YES')


n = int(input())
board = []
for _ in range(n):
	board.append(input())
if n == 1:
	print('YES')
	quit()
for i in range(n):
	for j in range(n):
		os = 0
		if i == 0:
			if j == 0:
				if board[i][j + 1] == 'o':
					os += 1
				if board[i + 1][j] == 'o':
					os += 1
			elif j == n - 1:
				if board[i][j - 1] == 'o':
					os += 1
				if board[i + 1][j] == 'o':
					os += 1
			else:
				if board[i][j - 1] == 'o':
					os += 1
				if board[i + 1][j] == 'o':
					os += 1
				if board[i][j + 1] == 'o':
					os += 1
		elif i == n - 1:
			if j == 0:
				if board[i][j + 1] == 'o':
					os += 1
				if board[i - 1][j] == 'o':
					os += 1
			elif j == n - 1:
				if board[i][j - 1] == 'o':
					os += 1
				if board[i - 1][j] == 'o':
					os += 1
			else:
				if board[i][j - 1] == 'o':
					os += 1
				if board[i - 1][j] == 'o':
					os += 1
				if board[i][j + 1] == 'o':
					os += 1
		elif j == 0:
			if board[i][j + 1] == 'o':
				os += 1
			if board[i + 1][j] == 'o':
				os += 1
			if board[i - 1][j] == 'o':
				os += 1
		elif j == n - 1:
			if board[i][j - 1] == 'o':
				os += 1
			if board[i + 1][j] == 'o':
				os += 1
			if board[i - 1][j] == 'o':
				os += 1
		else:
			if board[i][j - 1] == 'o':
				os += 1
			if board[i + 1][j] == 'o':
				os += 1
			if board[i][j + 1] == 'o':
				os += 1
			if board[i - 1][j] == 'o':
				os += 1
		if os % 2:
			print('NO')
			quit()
print('YES')


class Odd(Exception):
	pass
n = int(input())
c = 'o'
r = 0
board = []
for row in range(n):
	line = input()
	board.append([1 if col == c else 0 for col in line])
try:
	for i in range(n):
		for j in range(n):
			if ((board[i - 1][j] if i > 0 else 0) + (board[i + 1][j] if i < n - 1 else 0) + (board[i][j - 1] if j > 0 else 0) + (board[i][j + 1] if j < n - 1 else 0)) % 2:
				raise Odd
	print('YES')
except Odd:
	print('NO')


from sys import *
from math import *

def main():
	n = int(input())
	(r, c, a) = ([], [], [])
	for i in range(n):
		s = input()
		a.append(s)
	k = [[0, 1], [0, -1], [-1, 0], [1, 0]]
	for i in range(n):
		for j in range(n):
			ans = 0
			for d in k:
				x = i + d[0]
				y = j + d[1]
				if x > -1 and x < n and (y > -1) and (y < n):
					if a[x][y] == 'o':
						ans += 1
			if ans & 1 != 0:
				print('NO')
				return 0
	print('YES')
main()


n = int(input())
a = []
for i in range(n):
	st = input()
	a.append(st)
for i in range(len(a)):
	count = 0
	for j in range(len(a)):
		if i != 0:
			if a[i - 1][j] == 'o':
				count = count + 1
		if i < len(a) - 1:
			if a[i + 1][j] == 'o':
				count = count + 1
		if j != 0:
			if a[i][j - 1] == 'o':
				count = count + 1
		if j < len(a) - 1:
			if a[i][j + 1] == 'o':
				count = count + 1
		if count % 2 == 1:
			print('NO')
			exit()
print('YES')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = [S() for _ in range(n)]
	for i in range(n):
		for j in range(n):
			c = 0
			if i > 0 and a[i - 1][j] == 'o':
				c += 1
			if i < n - 1 and a[i + 1][j] == 'o':
				c += 1
			if j > 0 and a[i][j - 1] == 'o':
				c += 1
			if j < n - 1 and a[i][j + 1] == 'o':
				c += 1
			if c % 2 == 1:
				return 'NO'
	return 'YES'
print(main())


def main():
	n = int(input())
	s = []
	for i in range(n):
		s.append(input())
	for i in range(n):
		for j in range(n):
			cnt = 0
			for (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
				ii = i + di
				jj = j + dj
				if ii >= 0 and ii < n and (jj >= 0) and (jj < n) and (s[ii][jj] == 'o'):
					cnt += 1
			if cnt % 2:
				print('NO')
				return
	print('YES')
main()


n = int(input())
a = [(n + 2) * 'r']
for i in range(n):
	a.append('r' + input() + 'r')
a.append((n + 2) * 'r')
f = 'YES'
for i in range(1, n + 1):
	for j in range(1, n + 1):
		t = 0
		if a[i][j - 1] == 'o':
			t += 1
		if a[i - 1][j] == 'o':
			t += 1
		if a[i + 1][j] == 'o':
			t += 1
		if a[i][j + 1] == 'o':
			t += 1
		if t % 2 != 0:
			f = 'NO'
			break
	if f == 'NO':
		break
print(f)


n = int(input())
a = []
for z in range(n):
	a.append(list(input()))
for i in range(n):
	for j in range(n):
		count = 0
		if i < n - 1 and a[i + 1][j] == 'o':
			count += 1
		if i > 0 and a[i - 1][j] == 'o':
			count += 1
		if j < n - 1 and a[i][j + 1] == 'o':
			count += 1
		if j > 0 and a[i][j - 1] == 'o':
			count += 1
		if count % 2 == 1:
			print('NO')
			quit()
print('YES')


def get_adj(x, y):
	a = [(x, y + 1), (x, y - 1), (x + 1, y), (x - 1, y)]
	return [(i, j) for (i, j) in a if 0 <= i < n and 0 <= j < n]
n = int(input())
li = [input() for _ in range(n)]
yes = True
for d in range(n):
	for e in range(n):
		k = 0
		for (f, g) in get_adj(d, e):
			if li[f][g] == 'o':
				k += 1
		if k % 2:
			yes = False
print('YES' if yes else 'NO')


n = int(input())
mat = [[-1 for i in range(n + 2)] for j in range(n + 2)]
flag = 1
for i in range(1, n + 1):
	ll = input()
	ll = list(ll)
	for j in range(1, n + 1):
		mat[i][j] = ll[j - 1]
for k in range(1, n + 1):
	for l in range(1, n + 1):
		cnt = 0
		if mat[k][l - 1] == 'o':
			cnt += 1
		if mat[k][l + 1] == 'o':
			cnt += 1
		if mat[k - 1][l] == 'o':
			cnt += 1
		if mat[k + 1][l] == 'o':
			cnt += 1
		if cnt % 2 == 1:
			flag = 0
			print('NO')
			break
	if flag == 0:
		break
if flag == 1:
	print('YES')


n = int(input())
matriz = [['x'] + list(map(str, input())) + ['x'] for _ in range(n)]
matriz = [['x'] * (n + 2)] + matriz + [['x'] * (n + 2)]
flag = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if [matriz[i][j + 1], matriz[i][j - 1], matriz[i - 1][j], matriz[i + 1][j]].count('o') % 2 == 1:
			flag = False
			break
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
board = ''
for i in range(n):
	cell = input()
	board += cell
if board == board[::-1]:
	print('YES')
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(input())
f = 0
for i in range(n):
	for j in range(n):
		c = 0
		if i - 1 >= 0 and l[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and l[i + 1][j] == 'o':
			c += 1
		if j - 1 >= 0 and l[i][j - 1] == 'o':
			c += 1
		if j + 1 < n and l[i][j + 1] == 'o':
			c += 1
		if c & 1:
			f = 1
			break
	if f:
		break
if f:
	print('NO')
else:
	print('YES')


a = int(input())
li = [0] * a
x = 1
for i in range(a):
	li[i] = input()
for i in range(a):
	for j in range(a):
		count = 0
		if i - 1 >= 0:
			count += li[i - 1][j] == 'o'
		if i + 1 < a:
			count += li[i + 1][j] == 'o'
		if j - 1 >= 0:
			count += li[i][j - 1] == 'o'
		if j + 1 < a:
			count += li[i][j + 1] == 'o'
		if count % 2 != 0:
			print('NO')
			x = 0
			break
	if x == 0:
		break
if x:
	print('YES')


n = int(input())

def str_to_list(a):
	y = []
	for i in range(len(a)):
		y.append(a[i])
	return y
(a, d) = ([], 1)
for i in range(n):
	b = input()
	b1 = str_to_list(b)
	a.append(b1)
for i in range(n):
	for j in range(n):
		count = 0
		try:
			if a[i + 1][j] == 'o':
				count += 1
		except IndexError:
			pass
		try:
			if a[i - 1][j] == 'o' and i - 1 >= 0:
				count += 1
		except IndexError:
			pass
		try:
			if a[i][j + 1] == 'o':
				count += 1
		except IndexError:
			pass
		try:
			if a[i][j - 1] == 'o' and j - 1 >= 0:
				count += 1
		except IndexError:
			pass
		if count % 2 != 0:
			d += 1
if d == 1:
	print('YES')
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	s1 = input()
	s.append(s1)
if n == 1:
	if s[0] == 'o':
		print('YES')
	else:
		print('NO')
else:
	c = 0
	for i in range(n):
		for j in range(n):
			count = 0
			if j > 0:
				if s[i][j - 1] == 'o':
					count += 1
			if j < n - 1:
				if s[i][j + 1] == 'o':
					count += 1
			if i > 0:
				if s[i - 1][j] == 'o':
					count += 1
			if i < n - 1:
				if s[i + 1][j] == 'o':
					count += 1
			if count == 1 or count == 3:
				c = 1
				break
		if c == 1:
			break
	if c == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
L = [[n for n in input()] for i in range(n)]
left = right = up = down = 0

def count(n):
	if n == 'o':
		return 1
	else:
		return 0
f = 1
for i in range(n):
	for j in range(n):
		c = 0
		if i != 0:
			up = L[i - 1][j]
			c += count(up)
		if j != 0:
			left = L[i][j - 1]
			c += count(left)
		if j != n - 1:
			right = L[i][j + 1]
			c += count(right)
		if i != n - 1:
			down = L[i + 1][j]
			c += count(down)
		if c % 2 != 0:
			f = 0
			break
if f == 1:
	print('YES')
else:
	print('NO')


n = int(input())
check = [[0] * n for _ in range(n)]
for i in range(n):
	string = input()
	check[i] = list(string)
flag = True
for i in range(n):
	for j in range(n):
		count = 0
		if i - 1 >= 0 and check[i - 1][j] is 'o':
			count += 1
		if i + 1 < n and check[i + 1][j] is 'o':
			count += 1
		if j - 1 >= 0 and check[i][j - 1] is 'o':
			count += 1
		if j + 1 < n and check[i][j + 1] is 'o':
			count += 1
		if count % 2 != 0:
			flag = False
			break
print('YES' if flag is True else 'NO')


n = int(input())
a = []
for i in range(n):
	a.append(input())
message = 'YES'
for i in range(n):
	for j in range(n):
		count = 0
		if i != 0:
			if a[i - 1][j] == 'o':
				count += 1
		if i != n - 1:
			if a[i + 1][j] == 'o':
				count += 1
		if j != 0:
			if a[i][j - 1] == 'o':
				count += 1
		if j != n - 1:
			if a[i][j + 1] == 'o':
				count += 1
		if count % 2 != 0:
			message = 'NO'
			break
print(message)


n = int(input())
mat = []
for i in range(n):
	mat.append(list(input()))
cnt = 0
for i in range(n):
	for j in range(n):
		c = 0
		if j + 1 < n:
			if mat[i][j + 1] == 'o':
				c += 1
		if j - 1 >= 0:
			if mat[i][j - 1] == 'o':
				c += 1
		if i + 1 < n:
			if mat[i + 1][j] == 'o':
				c += 1
		if i - 1 >= 0:
			if mat[i - 1][j] == 'o':
				c += 1
		if c % 2 == 0:
			cnt += 1
if cnt == n * n:
	print('YES')
else:
	print('NO')


grid = []
n = None

def countAdj(i, j):
	cnt = 0
	if j < n - 1 and grid[i][j + 1] == 'o':
		cnt += 1
	if j > 0 and grid[i][j - 1] == 'o':
		cnt += 1
	if i < n - 1 and grid[i + 1][j] == 'o':
		cnt += 1
	if i > 0 and grid[i - 1][j] == 'o':
		cnt += 1
	return cnt
n = int(input())
for _ in range(n):
	grid.append(list(input()))
bv = True
for i in range(n):
	for j in range(n):
		if countAdj(i, j) % 2 != 0:
			bv = False
			break
if bv:
	print('YES')
else:
	print('NO')


n = int(input())
board = [input() for _ in range(n)]
for i in range(n):
	for j in range(n):
		c = 0
		for (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
			if i + di >= 0 and j + dj >= 0 and (i + di < n) and (j + dj < n):
				if board[i + di][j + dj] == 'o':
					c += 1
		if c % 2:
			print('NO')
			exit()
print('YES')


def solve(n):
	mp = []
	for i in range(n):
		mp.append(input())
	for i in range(n):
		for j in range(n):
			count = 0
			if i > 0 and mp[i - 1][j] == 'o':
				count = count + 1
			if j > 0 and mp[i][j - 1] == 'o':
				count = count + 1
			if i + 1 < n and mp[i + 1][j] == 'o':
				count = count + 1
			if j + 1 < n and mp[i][j + 1] == 'o':
				count = count + 1
			if count % 2 > 0:
				return False
	return True
n = int(input())
if solve(n):
	print('YES')
else:
	print('NO')


from sys import stdin

def main():
	n = int(stdin.readline().strip())
	l = [stdin.readline().strip() for _ in range(n)]
	c = [[False] * n for _ in range(n)]
	for y in range(n - 1):
		for x in range(n):
			c[y][x] ^= l[y + 1][x] == 'o'
			c[y + 1][x] ^= l[y][x] == 'o'
	for x in range(n - 1):
		for y in range(n):
			c[y][x] ^= l[y][x + 1] == 'o'
			c[y][x + 1] ^= l[y][x] == 'o'
	return ('YES', 'NO')[any(map(any, c))]
print(main())


n = int(input())
matrix = []
check = True
for i in range(0, n):
	row = list(input())
	matrix.append(row)
for i in range(0, n):
	for j in range(0, n):
		count = 0
		if i != 0:
			if matrix[i - 1][j] == 'o':
				count += 1
		if j != 0:
			if matrix[i][j - 1] == 'o':
				count += 1
		if i != n - 1:
			if matrix[i + 1][j] == 'o':
				count += 1
		if j != n - 1:
			if matrix[i][j + 1] == 'o':
				count += 1
		if count % 2 != 0:
			check = False
			break
			break
if check:
	print('YES')
else:
	print('NO')


n = int(input())
i = 0
thelist = []
while i < n:
	newline = input()
	j = 0
	newlist = []
	while j < len(newline):
		newlist.append(newline[j])
		j += 1
	thelist.append(newlist)
	i += 1
finallist = []
x = 0
y = 0
row = []
while y < len(thelist) + 2:
	row.append(0)
	y += 1
finallist.append(row)
for item in thelist:
	item_0 = [0]
	for x in item:
		if x == 'o':
			item_0.append(1)
		else:
			item_0.append(0)
	item_0.append(0)
	finallist.append(item_0)
finallist.append(row)
istrue = 'YES'
i = 1
j = 1
while i < len(finallist) - 1:
	while j < len(finallist) - 1:
		thecount = finallist[i - 1][j] + finallist[i + 1][j] + finallist[i][j - 1] + finallist[i][j + 1]
		if thecount % 2 == 1:
			istrue = 'NO'
		j += 1
	i += 1
	j = 1
print(istrue)


a = int(input())
b = []
for i in range(a):
	b.append(input())
true = 'YES'
for i in range(a):
	for j in range(a):
		total = 0
		for k in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
			try:
				if b[i + k[0]][j + k[1]] == 'o' and i + k[0] > -1 and (j + k[1] > -1):
					total += 1
			except IndexError:
				pass
		if total % 2:
			true = 'NO'
print(true)


n = int(input())
l = []
for i in range(n):
	l.append(list(input()))
y = True
for i in range(n):
	for j in range(n):
		k = 0
		if i - 1 >= 0 and l[i - 1][j] == 'o':
			k += 1
		if j - 1 >= 0 and l[i][j - 1] == 'o':
			k += 1
		if j + 1 < n and l[i][j + 1] == 'o':
			k += 1
		if i + 1 < n and l[i + 1][j] == 'o':
			k += 1
		if k % 2 > 0:
			y = False
			break
	if not y:
		break
print('YES' if y else 'NO')


n = int(input())
square = [list(input()) for i in range(n)]
is_correct = lambda x, y: 0 <= x < n and 0 <= y < n
os = [0] * (n * n)
for (y, row) in enumerate(square):
	for (x, char) in enumerate(row):
		if char == 'o':
			neighbours = [(x + 1, y), (x - 1, y), (x, y - 1), (x, y + 1)]
			for (j, i) in neighbours:
				if is_correct(i, j):
					os[i * n + j] += 1
if all(map(lambda x: not x % 2, os)):
	print('YES')
else:
	print('NO')


def matrix_protect(Matrix, a=0):
	Matrix.insert(0, [a] * len(Matrix[0]))
	Matrix.append([a] * len(Matrix[0]))
	for i in Matrix:
		i.insert(0, a)
		i.append(a)
n = int(input())
matrix = []
for i in range(n):
	matrix.append([str(x) for x in input()])
matrix_protect(matrix, '1')
flag = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		neighbour = matrix[i - 1][j] + matrix[i + 1][j] + matrix[i][j - 1] + matrix[i][j + 1]
		num = neighbour.count('o')
		if num % 2 == 1:
			flag = False
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
(table, adj, flag) = (['x' * (n + 1)], 0, True)
for i in range(0, n):
	table.append('x' + input() + 'x')
table.append('x' * (n + 1))
for i in range(1, n + 1):
	if not flag:
		break
	for j in range(1, n + 1):
		if (table[i + 1][j], table[i][j + 1], table[i - 1][j], table[i][j - 1]).count('o') % 2:
			print('NO')
			flag = False
			break
if flag:
	print('YES')


n = int(input())
p = []
for i in range(n):
	p.append(input())
z = 0
for i in range(n):
	for j in range(n):
		a = j + 1
		b = j - 1
		c = i + 1
		d = i - 1
		l = []
		if a > n - 1:
			pass
		else:
			l.append(p[i][a])
		if c > n - 1:
			pass
		else:
			l.append(p[c][j])
		if b < 0:
			pass
		else:
			l.append(p[i][b])
		if d < 0:
			pass
		else:
			l.append(p[d][j])
		if l.count('o') % 2 == 0:
			continue
		else:
			z = 1
			break
	if z == 1:
		break
if z == 1:
	print('NO')
else:
	print('YES')


def is_odd(matrix, i, j):
	num = 0
	if i > 0:
		num += matrix[i - 1][j] == 'o'
	if i < len(matrix) - 1:
		num += matrix[i + 1][j] == 'o'
	if j > 0:
		num += matrix[i][j - 1] == 'o'
	if j < len(matrix) - 1:
		num += matrix[i][j + 1] == 'o'
	return num % 2
num = int(input())
matrix = [input() for _ in range(num)]

def foo(num, matrix):
	for i in range(num):
		for j in range(num):
			if is_odd(matrix, i, j):
				print('NO')
				return
	print('YES')
foo(num, matrix)


tcs = int(input())
board = [['.'] * (tcs + 2)] + [['.'] + [x for x in input()] + ['.'] for i in range(tcs)] + [['.'] * (tcs + 2)]

def do(board, size):
	for i in range(1, size + 1):
		for j in range(1, size + 1):
			listx = [board[i + 1][j], board[i - 1][j], board[i][j - 1], board[i][j + 1]]
			if listx.count('o') % 2 != 0:
				return False
	return True
if do(board, tcs):
	print('YES')
else:
	print('NO')


li = []
n = int(input())
matrix = [[0 for i in range(n)] for i in range(n)]
for _ in range(n):
	l = input()
	li.append(l)
flag = 0
for i in range(n):
	for j in range(n):
		count = 0
		if j >= 1:
			if li[i][j - 1] == 'o':
				count = count + 1
		if j < n - 1:
			if li[i][j + 1] == 'o':
				count = count + 1
		if i < n - 1:
			if li[i + 1][j] == 'o':
				count = count + 1
		if i >= 1:
			if li[i - 1][j] == 'o':
				count = count + 1
		if count % 2 != 0:
			flag = 1
			break
			break
if flag == 0:
	print('YES')
else:
	print('NO')


n_val = int(input())
board = list()
for idx in range(n_val):
	board.append(input())
for row in range(n_val):
	for col in range(n_val):
		count = 0
		if row > 0:
			count += board[row - 1][col] == 'o'
		if row < n_val - 1:
			count += board[row + 1][col] == 'o'
		if col > 0:
			count += board[row][col - 1] == 'o'
		if col < n_val - 1:
			count += board[row][col + 1] == 'o'
		if count % 2 == 1:
			print('NO')
			exit(0)
print('YES')


def check(grid, n):
	for i in range(n):
		for j in range(n):
			count = 0
			if i != n - 1:
				if grid[i + 1][j] == 'o':
					count += 1
			if j != n - 1:
				if grid[i][j + 1] == 'o':
					count += 1
			if i != 0:
				if grid[i - 1][j] == 'o':
					count += 1
			if j != 0:
				if grid[i][j - 1] == 'o':
					count += 1
			if count % 2 != 0:
				return 'NO'
	return 'YES'
n = int(input())
grid = []
for i in range(n):
	x = input()
	m = list(x)
	grid.append(m)
print(check(grid, n))


n = int(input())
l_r = list((input() for _ in range(n)))
dx = [0, -1, 1, 0]
dy = [-1, 0, 0, 1]
for i in range(n):
	for j in range(n):
		t = 0
		for k in range(4):
			if i + dx[k] >= 0 and i + dx[k] < n:
				if j + dy[k] >= 0 and j + dy[k] < n:
					if l_r[i + dx[k]][j + dy[k]] == 'o':
						t += 1
		if t % 2 != 0:
			print('NO')
			quit()
print('YES')


n = int(input())
a = []
for i in range(n):
	a.append(str(input()))
f = True
j = 0
while f and j < n:
	for i in range(n):
		k = 0
		if i > 0 and a[j][i - 1] == 'o':
			k += 1
		if i < n - 1 and a[j][i + 1] == 'o':
			k += 1
		if j > 0 and a[j - 1][i] == 'o':
			k += 1
		if j < n - 1 and a[j + 1][i] == 'o':
			k += 1
		if k % 2 != 0:
			f = False
			break
	j += 1
if f:
	print('YES')
else:
	print('NO')


n = int(input())
xo = []
for a in range(n):
	x = input()
	xo.append(x)
stat = 'YES'
for b in range(n):
	for c in range(n):
		adj = 0
		try:
			if xo[b + 1][c] == 'o':
				adj += 1
		except:
			pass
		try:
			if xo[b - 1][c] == 'o' and b - 1 >= 0:
				adj += 1
		except:
			pass
		try:
			if xo[b][c + 1] == 'o':
				adj += 1
		except:
			pass
		try:
			if xo[b][c - 1] == 'o' and c - 1 >= 0:
				adj += 1
		except:
			pass
		if adj % 2 != 0:
			stat = 'NO'
print(stat)


n = int(input())
a = []
for i in range(n):
	a.append(list(input()))
flag = False
if n == 1:
	print('YES')
elif n == 2:
	c = 0
	if a[0][1] == 'o':
		c += 1
	if a[1][0] == 'o':
		c += 1
	if c % 2 == 1:
		flag = True
	c = 0
	if a[0][0] == 'o':
		c += 1
	if a[1][1] == 'o':
		c += 1
	if c % 2 == 1:
		flag = True
	if flag:
		print('NO')
	else:
		print('YES')
else:
	c = 0
	if a[0][1] == 'o':
		c += 1
	if a[1][0] == 'o':
		c += 1
	if c % 2 == 1:
		print('NO')
		exit()
	for i in range(1, n - 1):
		if a[0][i - 1] == 'o':
			c += 1
		if a[0][i + 1] == 'o':
			c += 1
		if a[1][i] == 'o':
			c += 1
		if c % 2 == 1:
			print('NO')
			exit()
	if a[n - 1][1] == 'o':
		c += 1
	if a[n - 2][0] == 'o':
		c += 1
	if c % 2 == 1:
		print('NO')
		exit()
	for i in range(1, n - 1):
		c = 0
		if a[i][1] == 'o':
			c += 1
		if a[i - 1][0] == 'o':
			c += 1
		if a[i + 1][0] == 'o':
			c += 1
		if c % 2 == 1:
			print('NO')
			exit()
		for j in range(1, n - 1):
			c = 0
			if a[i][j - 1] == 'o':
				c += 1
			if a[i][j + 1] == 'o':
				c += 1
			if a[i - 1][j] == 'o':
				c += 1
			if a[i + 1][j] == 'o':
				c += 1
			if c % 2 == 1:
				print('NO')
				exit()
		c = 0
		if a[i][n - 2] == 'o':
			c += 1
		if a[i - 1][n - 1] == 'o':
			c += 1
		if a[i + 1][n - 1] == 'o':
			c += 1
		if c % 2 == 1:
			print('NO')
			exit()
	if a[n - 2][0] == 'o':
		c += 1
	if a[n - 1][1] == 'o':
		c += 1
	if c % 2 == 1:
		print('NO')
		exit()
	for i in range(1, n - 1):
		if a[n - 1][i - 1] == 'o':
			c += 1
		if a[n - 1][i + 1] == 'o':
			c += 1
		if a[n - 2][i] == 'o':
			c += 1
		if c % 2 == 1:
			print('NO')
			exit()
	if a[n - 1][1] == 'o':
		c += 1
	if a[n - 2][0] == 'o':
		c += 1
	if c % 2 == 1:
		print('NO')
		exit()
	print('YES')


lines = int(input())
board = []
val = True
for i in range(0, lines):
	row = input().strip()
	board.append(row)
for i in range(0, lines):
	adjacent = 0
	for j in range(0, lines):
		if i < lines - 1:
			if board[i + 1][j] == 'o':
				adjacent += 1
		if i > 0:
			if board[i - 1][j] == 'o':
				adjacent += 1
		if j < lines - 1:
			if board[i][j + 1] == 'o':
				adjacent += 1
		if j > 0:
			if board[i][j - 1] == 'o':
				adjacent += 1
		if adjacent % 2 != 0:
			val = False
			break
if val:
	print('YES')
else:
	print('NO')


n = int(input())
l1 = []
flag = 0
for i in range(n):
	l2 = list(input())
	l1.append(l2)
flag = 0
for i in range(n):
	for j in range(n):
		c = 0
		if i + 1 < n:
			if l1[i + 1][j] == 'o':
				c += 1
		if i - 1 > -1:
			if l1[i - 1][j] == 'o':
				c += 1
		if j + 1 < n:
			if l1[i][j + 1] == 'o':
				c += 1
		if j - 1 > -1:
			if l1[i][j - 1] == 'o':
				c += 1
		if c % 2 == 1:
			flag = 1
			break
	if flag == 1:
		break
if flag == 1:
	print('NO')
else:
	print('YES')


X = ''
for i in range(int(input())):
	X += input()
print('YES' if X == X[::-1] else 'NO')


n = input()
p = int(n)
s = [[]] * p
tr = 1
z = 0
for j in range(0, p):
	ls = input()
	s[j] = [i for i in ls]
for j in range(0, p):
	for i in range(0, p):
		z = 0
		if i < p - 1:
			if s[j][i + 1] == 'o':
				z += 1
		if j < p - 1:
			if s[j + 1][i] == 'o':
				z += 1
		if i > 0:
			if s[j][i - 1] == 'o':
				z += 1
		if j > 0:
			if s[j - 1][i] == 'o':
				z += 1
		if z % 2 > 0:
			tr = 0
			break
if tr:
	print('YES')
else:
	print('NO')


n = int(input())
M = [str(input()) for _ in range(n)]
r = 1
for i in range(n):
	for j in range(n):
		if 1:
			a = 0
			if i:
				a += M[i - 1][j] == 'o'
			if j:
				a += M[i][j - 1] == 'o'
			if i < n - 1:
				a += M[i + 1][j] == 'o'
			if j < n - 1:
				a += M[i][j + 1] == 'o'
			if a % 2:
				r = 0
				print('NO')
				break
	if r == 0:
		break
if r:
	print('YES')


n = int(input())
board = [None] * n
for i in range(n):
	board[i] = input()

def is_inside(i, j, n):
	if 0 <= i and i < n and (0 <= j) and (j < n):
		return True
	else:
		return False
dx = [0, 0, 1, -1]
dy = [-1, 1, 0, 0]
ret = True
for j in range(n):
	for i in range(n):
		num_circle = 0
		for d in range(4):
			if is_inside(i + dx[d], j + dy[d], n):
				if board[i + dx[d]][j + dy[d]] == 'o':
					num_circle += 1
		if num_circle % 2 != 0:
			ret = False
if ret:
	print('YES')
else:
	print('NO')


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
N = int(input())
A = []
for i in range(N):
	A.append(list(input()))
for r in range(N):
	for c in range(N):
		count = 0
		for d in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
			(nr, nc) = (r + d[0], c + d[1])
			if 0 <= nr < N and 0 <= nc < N:
				if A[nr][nc] == 'o':
					count += 1
		if count % 2 != 0:
			print('NO')
			exit(0)
print('YES')


n = int(input())
board = []
for i in range(n):
	r = input()
	board.append(r)
can = True
for i in range(n):
	row = board[i]
	for j in range(n):
		ele = row[j]
		c = 0
		ind_r = [j + 1, j - 1]
		ind_c = [i + 1, i - 1]
		for k in range(2):
			if ind_r[k] >= n or ind_r[k] < 0:
				continue
			elif row[ind_r[k]] == 'o':
				c += 1
		for k in range(2):
			if ind_c[k] >= n or ind_c[k] < 0:
				continue
			elif board[ind_c[k]][j] == 'o':
				c += 1
		if c % 2 != 0:
			can = False
			break
	if can == False:
		break
if can == True:
	print('YES')
else:
	print('NO')


n = int(input())
A = []
s = ''
st = ''
for i in range(n + 2):
	st += 'x'
A.append(st)
for i in range(n):
	s = 'x' + input() + 'x'
	A.append(s)
A.append(st)
ans = 'YES'
for i in range(1, n + 1):
	for j in range(1, n + 1):
		c = 0
		if A[i + 1][j] == 'o':
			c += 1
		if A[i - 1][j] == 'o':
			c += 1
		if A[i][j + 1] == 'o':
			c += 1
		if A[i][j - 1] == 'o':
			c += 1
		if c % 2 == 0:
			continue
		else:
			ans = 'NO'
			break
print(ans)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
for i in range(n):
	for j in range(n):
		c = 0
		if i > 0:
			if l[i - 1][j] == 'o':
				c += 1
		if i < n - 1:
			if l[i + 1][j] == 'o':
				c += 1
		if j > 0:
			if l[i][j - 1] == 'o':
				c += 1
		if j < n - 1:
			if l[i][j + 1] == 'o':
				c += 1
		if c % 2 == 1:
			print('NO')
			exit()
print('YES')


n = int(input())
a = [input() for _ in range(n)]
ok = True
for i in range(n):
	for j in range(n):
		c = 0
		if i >= 1 and a[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and a[i + 1][j] == 'o':
			c += 1
		if j >= 1 and a[i][j - 1] == 'o':
			c += 1
		if j + 1 < n and a[i][j + 1] == 'o':
			c += 1
		ok &= c % 2 == 0
print('YES' if ok else 'NO')


def pad(a):
	l = [[0 for i in range(len(a[0]) + 2)]]
	for i in range(len(a)):
		c = [0]
		c += a[i]
		c += [0]
		l.append(c)
	l.append([0 for i in range(len(a[0]) + 2)])
	return l
n = int(input())
c = []
for i in range(n):
	s = list(input())
	c.append(s)
l = pad(c)
k = 0
for i in range(1, len(l) - 1):
	for j in range(1, len(l[i]) - 1):
		z = 0
		if l[i - 1][j] == 'o':
			z += 1
		if l[i][j - 1] == 'o':
			z += 1
		if l[i + 1][j] == 'o':
			z += 1
		if l[i][j + 1] == 'o':
			z += 1
		if z % 2 == 0:
			k += 1
if k == n * n:
	print('YES')
else:
	print('NO')


import sys

def o_s(i, j):
	ret = 0
	if board[i - 1][j] == 'o':
		ret += 1
	if board[i + 1][j] == 'o':
		ret += 1
	if board[i][j - 1] == 'o':
		ret += 1
	if board[i][j + 1] == 'o':
		ret += 1
	return ret
n = int(sys.stdin.readline())
board = ['x' * (n + 2)]
for i in range(n):
	board.append('x' + sys.stdin.readline().strip() + 'x')
board.append('x' * (n + 2))
even = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if o_s(i, j) % 2 == 1:
			even = False
		if not even:
			break
	if not even:
		break
if even:
	print('YES')
else:
	print('NO')


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
ls = lambda : list(input().strip())
from collections import defaultdict as df
import heapq
infinite = float('inf')
n = int(input())
l = [[] for i in range(n)]
for i in range(n):
	l[i] = ls()
f = 0
for i in range(n):
	for j in range(n):
		c = 0
		if i != 0:
			if l[i - 1][j] == 'o':
				c += 1
		if i != n - 1:
			if l[i + 1][j] == 'o':
				c += 1
		if j != 0:
			if l[i][j - 1] == 'o':
				c += 1
		if j != n - 1:
			if l[i][j + 1] == 'o':
				c += 1
		if c % 2 == 1:
			f = 1
			break
if f == 1:
	print('NO')
else:
	print('YES')


N = int(input())
board = [None] * N
for i in range(N):
	board[i] = input()
is_even = 0
for i in range(N):
	if is_even == 1:
		break
	for j in range(N):
		count_adjacent_cells = 0
		if i > 0 and board[i - 1][j] == 'o':
			count_adjacent_cells += 1
		if i < N - 1 and board[i + 1][j] == 'o':
			count_adjacent_cells += 1
		if j > 0 and board[i][j - 1] == 'o':
			count_adjacent_cells += 1
		if j < N - 1 and board[i][j + 1] == 'o':
			count_adjacent_cells += 1
		if count_adjacent_cells % 2 != 0:
			is_even = 1
			break
if is_even == 0:
	print('YES')
else:
	print('NO')


n = int(input())
lines = []
for i in range(n):
	lines.append(input())
if n > 1:
	flag = True
	for linei in range(n):
		for chari in range(n):
			counter = 0
			try:
				if lines[linei + 1][chari] == 'o':
					counter += 1
			except IndexError:
				pass
			try:
				if lines[linei - 1][chari] == 'o' and linei - 1 >= 0:
					counter += 1
			except IndexError:
				pass
			try:
				if lines[linei][chari + 1] == 'o':
					counter += 1
			except IndexError:
				pass
			try:
				if lines[linei][chari - 1] == 'o' and chari - 1 >= 0:
					counter += 1
			except IndexError:
				pass
			if counter % 2 != 0:
				flag = False
				break
else:
	flag = True
if flag:
	print('YES')
else:
	print('NO')


n = int(input())
square = [list(input()) for i in range(n)]
flag = True
for i in range(n):
	if flag == False:
		break
	for j in range(n):
		cc = 0
		if i > 0 and square[i - 1][j] == 'o':
			cc = cc + 1
		if i < n - 1 and square[i + 1][j] == 'o':
			cc = cc + 1
		if j > 0 and square[i][j - 1] == 'o':
			cc = cc + 1
		if j < n - 1 and square[i][j + 1] == 'o':
			cc = cc + 1
		if cc % 2 == 1:
			flag = False
			break
if flag:
	print('YES')
else:
	print('NO')


res = 'YES'
n = int(input())
board = [None] * n
for i in range(n):
	board[i] = input()
for i in range(n):
	for j in range(n):
		adj_o_cells_num = 0
		candidates = []
		for candidate in ([i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1]):
			if candidate[0] >= 0 and candidate[0] < n and (candidate[1] >= 0) and (candidate[1] < n):
				candidates.append(candidate)
		for candidate in candidates:
			if board[candidate[0]][candidate[1]] == 'o':
				adj_o_cells_num += 1
		if adj_o_cells_num % 2:
			res = 'NO'
			break
	if res == 'NO':
		break
print(res)


n = int(input())
board = []
for i in range(n + 2):
	if i == 0 or i == n + 1:
		line = ['x' for j in range(n + 2)]
	else:
		s = input()
		line = ['x']
		for c in s:
			line.append(c)
		line.append('x')
	board.append(line)
for i in range(1, n + 1):
	for j in range(1, n + 1):
		counter = 0
		if board[i - 1][j] == 'o':
			counter += 1
		if board[i + 1][j] == 'o':
			counter += 1
		if board[i][j - 1] == 'o':
			counter += 1
		if board[i][j + 1] == 'o':
			counter += 1
		if counter % 2 == 1:
			print('NO')
			exit()
print('YES')


size = int(input())
lines = []
for _ in range(size):
	lines.append(input())

def getIndexOfNeighoringTiles(i, j):
	neighbors = []
	if j % size != 0:
		neighbors.append(lines[i][j - 1])
	if j % size != size - 1:
		neighbors.append(lines[i][j + 1])
	if i % size != 0:
		neighbors.append(lines[i - 1][j])
	if i % size != size - 1:
		neighbors.append(lines[i + 1][j])
	return neighbors

def main(size, lines):
	for i in range(size):
		for j in range(size):
			neighbors = getIndexOfNeighoringTiles(i, j)
			count = neighbors.count('o')
			if count % 2 != 0:
				return False
	return True
thing = main(size, lines)
if thing == True:
	print('YES')
else:
	print('NO')


def check(i, j, matrix):
	counter = 0
	for new_position in [(0, 1), (0, -1), (-1, 0), (1, 0)]:
		node_position = (i + new_position[0], j + new_position[1])
		if node_position[0] < 0 or node_position[0] > len(matrix) - 1 or node_position[1] < 0 or (node_position[1] > len(matrix[node_position[0]]) - 1):
			continue
		if matrix[node_position[0]][node_position[1]] == 'o':
			counter += 1
	return counter

def apple_man():
	size_matrix = int(input())
	matrix = []
	for i in range(size_matrix):
		matrix.append(input())
	for i in range(len(matrix)):
		for j in range(len(matrix[i])):
			temp = check(i, j, matrix)
			if temp % 2 != 0:
				return 'NO'
	return 'YES'
A = apple_man()
print(A)


def check(m, n):
	for i in range(n):
		for j in range(n):
			cnt = 0
			if i + 1 >= 0 and i + 1 < n and (m[i + 1][j] == 'o'):
				cnt += 1
			if i - 1 >= 0 and i - 1 < n and (m[i - 1][j] == 'o'):
				cnt += 1
			if j + 1 >= 0 and j + 1 < n and (m[i][j + 1] == 'o'):
				cnt += 1
			if j - 1 >= 0 and j - 1 < n and (m[i][j - 1] == 'o'):
				cnt += 1
			if cnt % 2 == 1:
				return False
	return True
n = int(input())
m = []
for i in range(n):
	m.append([ch for ch in input()])
if check(m, n):
	print('YES')
else:
	print('NO')


n = int(input())
l = []
for _ in range(n):
	b = list(input().split())
	l.append(b[0])
m = len(l[0])
e = 0
for i in range(n):
	for j in range(m):
		c = 0
		if i - 1 >= 0 and l[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and l[i + 1][j] == 'o':
			c += 1
		if j - 1 >= 0 and l[i][j - 1] == 'o':
			c += 1
		if j + 1 < m and l[i][j + 1] == 'o':
			c += 1
		if c == 1 or c == 3:
			break
		else:
			e += 1
	else:
		continue
	break
if e != n * m:
	print('NO')
else:
	print('YES')


gi = lambda : list(map(int, input().strip().split()))
(n,) = gi()
g = [list(input()) for _ in range(n)]
g = [[0 if e[k] == 'x' else 1 for k in range(n)] for e in g]
for k in range(n):
	for j in range(n):
		temp = 0
		if 0 <= j + 1 < n:
			temp += g[k][j + 1]
		if 0 <= j - 1 < n:
			temp += g[k][j - 1]
		if 0 <= k + 1 < n:
			temp += g[k + 1][j]
		if 0 <= k - 1 < n:
			temp += g[k - 1][j]
		if temp % 2:
			print('NO')
			exit()
print('YES')


def valid_index(x, y):
	return x >= 0 and y >= 0 and (x < n) and (y < n)
n = int(input())
arr = []
for i in range(n):
	s = str(input())
	arr.append(s)
for i in range(n):
	for j in range(n):
		cnt = 0
		if valid_index(i - 1, j) and arr[i - 1][j] == 'o':
			cnt += 1
		if valid_index(i + 1, j) and arr[i + 1][j] == 'o':
			cnt += 1
		if valid_index(i, j - 1) and arr[i][j - 1] == 'o':
			cnt += 1
		if valid_index(i, j + 1) and arr[i][j + 1] == 'o':
			cnt += 1
		if cnt in [1, 3]:
			print('NO')
			exit()
print('YES')


def check(i, j, Matrix, num_input):
	ans = 0
	if j != 0:
		if Matrix[i][j - 1] == 'o':
			ans += 1
	if j != num_input - 1:
		if Matrix[i][j + 1] == 'o':
			ans += 1
	if i != 0:
		if Matrix[i - 1][j] == 'o':
			ans += 1
	if i != num_input - 1:
		if Matrix[i + 1][j] == 'o':
			ans += 1
	if ans % 2 == 0:
		return True
	else:
		return False
num_input = int(input())
Matrix = [[0 for x in range(num_input + 1)] for x in range(num_input + 1)]
for i in range(0, num_input):
	str = input()
	Matrix[i] = str
ans_count = 0
fact = 0
for i in range(0, num_input):
	for j in range(0, num_input):
		if fact == 0 and check(i, j, Matrix, num_input) == False:
			fact = 1
if fact == 1:
	print('NO')
else:
	print('YES')


n = int(input())
l = []
for i in range(n):
	temp = input()
	l.append(temp)
flag = 0
for i in range(0, n):
	count = 0
	for j in range(0, n):
		if i - 1 >= 0 and l[i - 1][j] == 'o':
			count += 1
		if i + 1 < n and l[i + 1][j] == 'o':
			count += 1
		if j - 1 >= 0 and l[i][j - 1] == 'o':
			count += 1
		if j + 1 < n and l[i][j + 1] == 'o':
			count += 1
		if count % 2 == 1:
			flag = 1
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
s = 0
c1 = 0
a = [[0] * n for i in range(n)]
for i in range(n):
	tmp = input()
	for j in range(len(tmp)):
		a[i][j] = tmp[j]
for i in range(len(a)):
	for j in range(len(a[i])):
		s = 0
		if i - 1 >= 0:
			if a[i - 1][j] == 'o':
				s = s + 1
		if j - 1 >= 0:
			if a[i][j - 1] == 'o':
				s = s + 1
		if i + 1 < len(a):
			if a[i + 1][j] == 'o':
				s = s + 1
		if j + 1 < n:
			if a[i][j + 1] == 'o':
				s = s + 1
		if s % 2 != 0:
			c1 = -1
			break
	if c1 == -1:
		break
if c1 == 0:
	print('YES')
else:
	print('NO')


n = int(input())
c = ''
for i in range(n):
	c += input()
print('YES' if c == c[::-1] else 'NO')


n = int(input())
l = []
for i in range(n):
	l1 = input()
	l.append(l1)
flag = 0
for i in range(n):
	for j in range(n):
		s = 0
		if i != 0:
			if l[i - 1][j] == 'o':
				s += 1
		if j != 0:
			if l[i][j - 1] == 'o':
				s += 1
		if i != n - 1:
			if l[i + 1][j] == 'o':
				s += 1
		if j != n - 1:
			if l[i][j + 1] == 'o':
				s += 1
		if s % 2 != 0:
			flag = 1
			break
if flag:
	print('NO')
else:
	print('YES')


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l
mod = int(1000000000.0) + 7

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)

def p2(a, b):
	print(a, b)
n = iinp()
f = 0
s = ''
for i in range(n):
	s += sinp()
if s[::-1] == s:
	print('YES')
else:
	print('NO')


n = int(input())
Answer = True
a = []
number = 0
for i in range(n):
	a.append(list(input()))
counter = 0
for i in range(n):
	for j in range(n):
		counter = 0
		if i + 1 >= 0 and i + 1 < n and (a[i + 1][j] == 'o'):
			counter += 1
		if i - 1 >= 0 and i - 1 < n and (a[i - 1][j] == 'o'):
			counter += 1
		if j + 1 >= 0 and j + 1 < n and (a[i][j + 1] == 'o'):
			counter += 1
		if j - 1 >= 0 and j - 1 < n and (a[i][j - 1] == 'o'):
			counter += 1
		if counter % 2 == 1:
			print('NO')
			exit(0)
print('YES')


n = int(input())
a = []
c = 0
r = 0
for i in range(n):
	a.append([])
	b = input()
	for j in range(n):
		a[i].append(b[j])
for i in range(n):
	for j in range(n):
		c = 0
		if i < n - 1:
			if a[i + 1][j] == 'o':
				c += 1
		if j < n - 1:
			if a[i][j + 1] == 'o':
				c += 1
		if i > 0:
			if a[i - 1][j] == 'o':
				c += 1
		if j > 0:
			if a[i][j - 1] == 'o':
				c += 1
		if c % 2 == 0:
			r += 1
if r == n * n:
	print('YES')
else:
	print('NO')


def countAdj(grid, n, i, j):
	c = 0
	if i + 1 < n:
		if grid[i + 1][j] == 'o':
			c += 1
	if j + 1 < n:
		if grid[i][j + 1] == 'o':
			c += 1
	if i - 1 >= 0:
		if grid[i - 1][j] == 'o':
			c += 1
	if j - 1 >= 0:
		if grid[i][j - 1] == 'o':
			c += 1
	return c

def weGood(grid):
	for i in range(n):
		for j in range(n):
			if countAdj(grid, n, i, j) % 2 != 0:
				return False
	return True
grid = []
n = int(input().strip())
for i in range(n):
	grid.append(list(input().strip()))
print(['NO', 'YES'][weGood(grid)])


(n, l, flag, o) = (int(input()), [], True, 0)
for i in range(n):
	l.append('0')
	l[i] = str(input())
for i in range(n):
	for el in range(n):
		if el - 1 >= 0:
			if l[i][el - 1] == 'o':
				o += 1
		if el + 1 < n:
			if l[i][el + 1] == 'o':
				o += 1
		if i - 1 >= 0:
			if l[i - 1][el] == 'o':
				o += 1
		if i + 1 < n:
			if l[i + 1][el] == 'o':
				o += 1
		flag &= o % 2 == 0
if flag:
	print('YES')
else:
	print('NO')


def even_adjacent(n, board):
	i = 1
	j = 1
	while i < n + 1:
		j = 1
		while j < n + 1:
			times = 0
			if board[i][j - 1] == 'o':
				times += 1
			if board[i][j + 1] == 'o':
				times += 1
			if board[i - 1][j] == 'o':
				times += 1
			if board[i + 1][j] == 'o':
				times += 1
			if times % 2 != 0:
				return 'NO'
			j += 1
		i += 1
	return 'YES'
n = int(input())
board = [['x'] * (n + 2)]
for x in range(n):
	q = list(input())
	q.insert(0, 'x')
	q.append('x')
	board.append(q)
board.append(['x'] * (n + 2))
print(even_adjacent(n, board))


n = int(input())
a = [str(input()) for i in range(n)]
d = 1
c = 0
for i in range(n):
	if d != 0:
		for j in range(n):
			if i > 0:
				if a[i - 1][j] == 'o':
					c += 1
			if i < n - 1:
				if a[i + 1][j] == 'o':
					c += 1
			if j > 0:
				if a[i][j - 1] == 'o':
					c += 1
			if j < n - 1:
				if a[i][j + 1] == 'o':
					c += 1
			if c % 2 != 0:
				d = 0
				print('NO')
				break
if d == 1:
	print('YES')


n = int(input())
a = ['x' * (n + 2)] + ['x' + input() + 'x' for i in range(n)] + ['x' * (n + 2)]

def f(i, j):
	c = 0
	if a[i - 1][j] == 'o':
		c += 1
	if a[i][j - 1] == 'o':
		c += 1
	if a[i + 1][j] == 'o':
		c += 1
	if a[i][j + 1] == 'o':
		c += 1
	return c % 2 == 0
print('YES' if all((f(i + 1, j + 1) for i in range(n) for j in range(n))) else 'NO')


def is_valid(s):
	for i in range(n):
		for j in range(n):
			cnt = 0
			if i > 0 and s[i - 1][j] == 'o':
				cnt += 1
			if i < n - 1 and s[i + 1][j] == 'o':
				cnt += 1
			if j > 0 and s[i][j - 1] == 'o':
				cnt += 1
			if j < n - 1 and s[i][j + 1] == 'o':
				cnt += 1
			if cnt % 2:
				return False
	return True
n = int(input())
s = [[c for c in input()] for i in range(n)]
print('YES' if is_valid(s) else 'NO')


from sys import stdin, stdout
n = int(stdin.readline().strip())
board = []
row_0 = list((n + 1) * 'e')
board.append(row_0)
for i in range(n):
	row = list(stdin.readline().strip())
	row.insert(0, 'e')
	row.append('e')
	board.append(row)
last_row = list((n + 1) * 'e')
board.append(last_row)
bool_value = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		nbors = [board[i][j + 1], board[i + 1][j], board[i][j - 1], board[i - 1][j]]
		if nbors.count('o') % 2 != 0:
			bool_value = False
			break
	if bool_value == False:
		break
if bool_value:
	stdout.write('YES')
else:
	stdout.write('NO')


n = int(input())
A = [[0] * n] + [list(input()) for _ in range(n)] + [[0] * n]
for i in range(len(A)):
	A[i] = [0] + A[i] + [0]
for i in range(1, len(A) - 1):
	for j in range(1, len(A) - 1):
		cnt = 0
		for (kek, lol) in ((i, j + 1), (i, j - 1), (i - 1, j), (i + 1, j)):
			if kek != i or lol != j:
				if A[kek][lol] == 'o':
					cnt += 1
		if cnt % 2:
			print('NO')
			exit(0)
print('YES')


from builtins import range
n = int(input())
i = 0
g = 0
desk = [[]]
for i in range(n):
	str = input()
	desk.insert(i, [str[g] for g in range(n)])
i = 0
g = 0
test = True
for i in range(n):
	for g in range(n):
		res = 0
		if i - 1 != -1:
			if desk[i - 1][g] == 'o':
				res += 1
		if i + 1 < n:
			if desk[i + 1][g] == 'o':
				res += 1
		if g - 1 != -1:
			if desk[i][g - 1] == 'o':
				res += 1
		if g + 1 < n:
			if desk[i][g + 1] == 'o':
				res += 1
		if res % 2 == 1:
			test = False
			break
	if test == False:
		break
if test == True:
	print('YES')
else:
	print('NO')


rows = int(input())
matrix = []
for i in range(0, rows):
	matrix.append(str(input()))
matrix2 = []
for i in range(0, len(matrix)):
	matrix2.append([])
	for c in matrix[i]:
		matrix2[i].append(0)
for i in range(0, len(matrix)):
	for j in range(0, len(matrix[i])):
		if matrix[i][j] == 'o':
			if i > 0:
				matrix2[i - 1][j] += 1
			if i < len(matrix) - 1:
				matrix2[i + 1][j] += 1
			if j > 0:
				matrix2[i][j - 1] += 1
			if j < len(matrix[i]) - 1:
				matrix2[i][j + 1] += 1
outString = 'YES'
for a in matrix2:
	for b in a:
		if b % 2 == 1:
			outString = 'NO'
print(outString)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	data = []
	for i in range(n):
		data.append(insr())
	moves = [(-1, 0), (1, 0), (0, 1), (0, -1)]
	ok = True
	for i in range(n):
		for j in range(n):
			c = 0
			for m in moves:
				x = i + m[0]
				y = j + m[1]
				if 0 <= x < n and 0 <= y < n and (data[x][y] == 'o'):
					c += 1
			if c % 2 != 0:
				ok = False
	print('YES' if ok else 'NO')
main()


def valid(i):
	return i >= 0 and i < n
n = int(input())
a = []
for i in range(n):
	s = input()
	a.append(s)
for i in range(n):
	for j in range(n):
		c = 0
		if valid(i + 1) and a[i + 1][j] == 'o':
			c += 1
		if valid(i - 1) and a[i - 1][j] == 'o':
			c += 1
		if valid(j + 1) and a[i][j + 1] == 'o':
			c += 1
		if valid(j - 1) and a[i][j - 1] == 'o':
			c += 1
		if c % 2 != 0:
			print('NO')
			quit()
print('YES')


def count(i, j, M):
	an = 0
	if i > 0:
		if M[i - 1][j] == 'o':
			an += 1
	if i < len(M) - 1:
		if M[i + 1][j] == 'o':
			an += 1
	if j > 0:
		if M[i][j - 1] == 'o':
			an += 1
	if j < len(M) - 1:
		if M[i][j + 1] == 'o':
			an += 1
	return an
n = int(input())
M = []
for i in range(n):
	M += [input()]
f = True
for i in range(n):
	for j in range(n):
		if count(i, j, M) % 2 != 0:
			f = False
			break
if f:
	print('YES')
else:
	print('NO')


p = 1
n = int(input())
grid = []
for i in range(0, n):
	grid.append(input())
difx = (1, -1, 0, 0)
dify = (0, 0, -1, 1)
for i in range(0, n):
	for j in range(0, n):
		count = 0
		for c in range(0, 4):
			x = i + difx[c]
			y = j + dify[c]
			if x < 0 or x >= n or y < 0 or (y >= n):
				continue
			if grid[x][y] == 'o':
				count += 1
		if count % 2 != 0:
			p = 0
if p == 1:
	print('YES')
else:
	print('NO')


n = int(input())
checkerboard = []
for i in range(n):
	checkerboard.append(input())
is_all_even = True
for i in range(n):
	for j in range(n):
		o_neighbours = 0
		(l, r) = (j - 1, j + 1)
		(u, d) = (i - 1, i + 1)
		if l >= 0 and checkerboard[i][l] == 'o':
			o_neighbours += 1
		if r < n and checkerboard[i][r] == 'o':
			o_neighbours += 1
		if u >= 0 and checkerboard[u][j] == 'o':
			o_neighbours += 1
		if d < n and checkerboard[d][j] == 'o':
			o_neighbours += 1
		if o_neighbours % 2 != 0:
			is_all_even = False
	if not is_all_even:
		break
if is_all_even:
	print('YES')
else:
	print('NO')


n = int(input())
mat = []
mat.append('x' * (n + 2))
for i in range(n):
	mat.append('x' + input() + 'x')
mat.append('x' * (n + 2))
output = 'YES'
for i in range(1, n + 1):
	if output == 'NO':
		break
	for j in range(1, n + 1):
		s = 0
		if mat[i][j + 1] == 'o':
			s += 1
		if mat[i][j - 1] == 'o':
			s += 1
		if mat[i + 1][j] == 'o':
			s += 1
		if mat[i - 1][j] == 'o':
			s += 1
		if s % 2:
			output = 'NO'
			break
print(output)


def func():
	n = int(input())
	s = []
	tt = ''
	for i in range(n):
		tt = tt + 'xx'
	s.append(tt)
	for i in range(n):
		st = input()
		s.append('x' + st + 'xxxxxxxxxxx')
	s.append(tt)
	for i in range(1, n + 1):
		for j in range(1, n + 1):
			c = 0
			if s[i][j - 1] == 'o':
				c += 1
			if s[i][j + 1] == 'o':
				c += 1
			if s[i - 1][j] == 'o':
				c += 1
			if s[i + 1][j] == 'o':
				c += 1
			if c % 2 == 1:
				print('NO')
				return
	print('YES')
func()


n = int(input())
a = []
for _ in range(n):
	a.append(input().strip())
for i in range(n):
	ok = True
	for j in range(n):
		nb = 0
		if i >= 1 and a[i - 1][j] == 'o':
			nb += 1
		if i <= n - 2 and a[i + 1][j] == 'o':
			nb += 1
		if j >= 1 and a[i][j - 1] == 'o':
			nb += 1
		if j <= n - 2 and a[i][j + 1] == 'o':
			nb += 1
		if nb % 2 != 0:
			ok = False
			break
	if ok == False:
		print('NO')
		break
else:
	print('YES')


def fun():
	n = int(input())
	a = []
	for _ in range(n):
		a.append(input())
	for (row, v) in enumerate(a):
		for (col, c) in enumerate(v):
			os = 0
			if row - 1 >= 0 and a[row - 1][col] == 'o':
				os += 1
			if col - 1 >= 0 and a[row][col - 1] == 'o':
				os += 1
			if row + 1 < n and a[row + 1][col] == 'o':
				os += 1
			if col + 1 < n and a[row][col + 1] == 'o':
				os += 1
			if os % 2 != 0:
				return 'NO'
	return 'YES'
print(fun())


n = int(input())
l = [[0] * (n + 2)]
c = 0
for i in range(n):
	l.append([0] + list(input()) + [0])
l.append([0] * (n + 2))
flag = 'YES'
for i in range(1, n + 1):
	c = 0
	if flag == 'NO':
		break
	for j in range(1, n + 1):
		if l[j - 1][i] == 'o':
			c += 1
		if l[j + 1][i] == 'o':
			c += 1
		if l[j][i - 1] == 'o':
			c += 1
		if l[j][i + 1] == 'o':
			c += 1
		if c % 2 != 0:
			flag = 'NO'
print(flag)


n = int(input())
a = []
for i in range(0, n):
	a.append(input())
s = ''
for i in range(0, n):
	s = s + 't'
a.append(s)
a.insert(0, s)
for i in range(0, len(a)):
	a[i] = 't' + a[i] + 't'
flag = 0
for i in range(1, n + 1):
	c = 0
	for j in range(1, n + 1):
		if a[i][j + 1] == 'o':
			c += 1
		if a[i][j - 1] == 'o':
			c += 1
		if a[i + 1][j] == 'o':
			c += 1
		if a[i - 1][j] == 'o':
			c += 1
		if c % 2 == 0:
			flag += 1
if flag == n * n:
	print('YES')
else:
	print('NO')


n = int(input())
mat = []
b = True
for _ in range(n):
	s = list(map(str, input().split()))
	mat.append(s)
col = 0
a = True
for row in range(n):
	if not a:
		break
	for val in range(n):
		c = 0
		if val + 1 < n and mat[row][col][val + 1] == 'o':
			c += 1
		if row + 1 < n and mat[row + 1][col][val] == 'o':
			c += 1
		if val > 0 and mat[row][col][val - 1] == 'o':
			c += 1
		if row - 1 >= 0 and mat[row - 1][col][val] == 'o':
			c += 1
		if c % 2 == 0:
			b = True
		else:
			b = False
			a = False
			break
if b:
	print('YES')
else:
	print('NO')


n = int(input())
M = [input() for i in range(n)]
c = 0
for i in range(n):
	for j in range(n):
		k = 0
		if i > 0:
			if M[i - 1][j] == 'o':
				k = k + 1
		if i < n - 1:
			if M[i + 1][j] == 'o':
				k = k + 1
		if j > 0:
			if M[i][j - 1] == 'o':
				k = k + 1
		if j < n - 1:
			if M[i][j + 1] == 'o':
				k = k + 1
		if k != 0 and k % 2 != 0:
			c = 1
			break
			break
if c == 0:
	print('YES')
else:
	print('NO')


n = int(input())
A = []
for i in range(0, n):
	s = input()
	B = []
	for j in s:
		if j == 'x':
			B.append(0)
		elif j == 'o':
			B.append(1)
	A.append(B)
flag = 0
for k in range(0, n):
	if n == 1:
		break
	for l in range(0, n):
		if k == 0:
			if l == 0:
				count = A[k][l + 1] + A[k + 1][l]
			elif l == n - 1:
				count = A[k][l - 1] + A[k + 1][l]
			else:
				count = A[k][l + 1] + A[k][l - 1] + A[k + 1][l]
		elif k == n - 1:
			if l == 0:
				count = A[k][l + 1] + A[k - 1][l]
			elif l == n - 1:
				count = A[k][l - 1] + A[k - 1][l]
			else:
				count = A[k][l + 1] + A[k][l - 1] + A[k - 1][l]
		elif l == 0:
			count = A[k][l + 1] + A[k + 1][l] + A[k - 1][l]
		elif l == n - 1:
			count = A[k][l - 1] + A[k + 1][l] + A[k - 1][l]
		else:
			count = A[k][l + 1] + +A[k][l - 1] + A[k + 1][l] + A[k - 1][l]
		if count % 2 != 0:
			flag = 1
			break
if flag == 0:
	print('YES')
else:
	print('NO')


def func(n, board):
	if n == 1:
		return 'YES'
	for row in range(len(board)):
		num_o = 0
		for col in range(len(board[0])):
			if col == 0:
				if board[row][col + 1] == 'o':
					num_o += 1
			elif col == len(board) - 1:
				if board[row][col - 1] == 'o':
					num_o += 1
			else:
				if board[row][col + 1] == 'o':
					num_o += 1
				if board[row][col - 1] == 'o':
					num_o += 1
			if row == 0:
				if board[row + 1][col] == 'o':
					num_o += 1
			elif row == len(board) - 1:
				if board[row - 1][col] == 'o':
					num_o += 1
			else:
				if board[row + 1][col] == 'o':
					num_o += 1
				if board[row - 1][col] == 'o':
					num_o += 1
			if num_o % 2 != 0:
				return 'NO'
	return 'YES'
n = int(input())
board = []
for _ in range(n):
	row = [i for i in input()]
	board.append(row)
print(func(n, board))


import sys
n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(str, input())))
for i in range(n):
	for j in range(n):
		total = 0
		if i > 0:
			if arr[i - 1][j] == 'o':
				total += 1
		if i < n - 1:
			if arr[i + 1][j] == 'o':
				total += 1
		if j > 0:
			if arr[i][j - 1] == 'o':
				total += 1
		if j < n - 1:
			if arr[i][j + 1] == 'o':
				total += 1
		if total % 2 != 0:
			print('NO')
			sys.exit()
print('YES')


n = int(input())
a = [input() for i in range(n)]
if n == 1:
	print('YES')
else:
	ans = True
	c = 0
	for i in range(n):
		for j in range(n):
			if i == 0 and j == 0:
				c += int(a[i + 1][j] == 'o') + int(a[i][j + 1] == 'o')
			elif i == n - 1 and j == n - 1:
				c += int(a[i - 1][j] == 'o') + int(a[i][j - 1] == 'o')
			elif i == 0 and j == n - 1:
				c += int(a[i + 1][j] == 'o') + int(a[i][j - 1] == 'o')
			elif i == n - 1 and j == 0:
				c += int(a[i - 1][j] == 'o') + int(a[i][j + 1] == 'o')
			elif i == 0:
				c += int(a[i + 1][j] == 'o') + int(a[i][j + 1] == 'o') + int(a[i][j - 1] == 'o')
			elif i == n - 1:
				c += int(a[i - 1][j] == 'o') + int(a[i][j + 1] == 'o') + int(a[i][j - 1] == 'o')
			elif j == 0:
				c += int(a[i + 1][j] == 'o') + int(a[i - 1][j] == 'o') + int(a[i][j + 1] == 'o')
			elif j == n - 1:
				c += int(a[i + 1][j] == 'o') + int(a[i - 1][j] == 'o') + int(a[i][j - 1] == 'o')
			else:
				c += int(a[i + 1][j] == 'o') + int(a[i][j + 1] == 'o') + int(a[i][j - 1] == 'o') + int(a[i - 1][j] == 'o')
			if c % 2 != 0:
				ans = False
	print(['NO', 'YES'][ans])


(n, a, cnt) = (int(input()), [], 0)
a.append('x' * n + 'xx')
for i in range(n):
	a.append('x' + input() + 'x')
a.append('x' * n + 'xx')
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if ((a[i - 1][j] == 'o') + (a[i + 1][j] == 'o') + (a[i][j - 1] == 'o') + (a[i][j + 1] == 'o')) % 2:
			print('NO')
			exit()
print('YES')


n = int(input())
A = []
B = []
c = 0
for i in range(n):
	A.append(list(input()))
for i in range(n):
	for j in range(len(A[i])):
		if j != len(A[i]) - 1:
			if A[i][j + 1] == 'o':
				c += 1
		if i != len(A) - 1:
			if A[i + 1][j] == 'o':
				c += 1
		if j != 0:
			if A[i][j - 1] == 'o':
				c += 1
		if i != 0:
			if A[i - 1][j] == 'o':
				c += 1
	B.append(c)
	c = 0
if len(B) == 2:
	if A[0] == A[1][::-1]:
		print('YES')
	else:
		print('NO')
else:
	for i in B:
		if i % 2 != 0:
			print('NO')
			break
	else:
		print('YES')


def fuc(b):
	a = []
	for i in b:
		it = []
		for x in i:
			if x == 'o':
				it.append(1)
			else:
				it.append(0)
		a.append(it)
		it = []
	return a

def ifo(i, x):
	global a
	if (a[i][x - 1] + a[i][x + 1] + a[i - 1][x] + a[i + 1][x]) % 2 == 0:
		return True
	return False
s = int(input())
a = fuc([[x for x in input()] for _ in range(s)])
key = True
if s == 1:
	print('YES')
else:
	if (a[0][1] + a[1][0]) % 2 != 0:
		key = False
	elif (a[0][s - 2] + a[1][s - 1]) % 2 != 0:
		key = False
	elif (a[s - 2][0] + a[s - 1][1]) % 2 != 0:
		key = False
	elif (a[s - 2][s - 1] + a[s - 1][s - 2]) % 2 != 0:
		key = False
	if key:
		for i in range(1, s - 1):
			if (a[0][i - 1] + a[1][i] + a[0][i + 1]) % 2 != 0:
				key = False
			elif (a[i - 1][0] + a[i][1] + a[i + 1][0]) % 2 != 0:
				key = False
			elif (a[s - 1][i - 1] + a[s - 2][i] + a[s - 1][i + 1]) % 2 != 0:
				key = False
			elif (a[i - 1][s - 1] + a[i][s - 2] + a[i + 1][s - 1]) % 2 != 0:
				key = False
			if not key:
				print('NO')
				break
	else:
		print('NO')
	if key:
		for i in range(1, s - 1):
			for j in range(1, s - 1):
				if ifo(i, j):
					continue
				else:
					key = False
					break
			if not key:
				break
		if key:
			print('YES')
		else:
			print('NO')


def check(data, i, j):
	count = 0
	if i > 0 and data[i - 1][j] == 'o':
		count += 1
	if i + 1 < n and data[i + 1][j] == 'o':
		count += 1
	if j + 1 < n and data[i][j + 1] == 'o':
		count += 1
	if j > 0 and data[i][j - 1] == 'o':
		count += 1
	return count % 2 == 0
data = []
n = int(input())
for _ in range(n):
	data.append(input())
for i in range(n):
	for j in range(n):
		if not check(data, i, j):
			print('NO')
			exit()
print('YES')


n = int(input())
a = ['#' * (n + 2)]
for i in range(1, n + 1):
	a.append('#')
	a[i] += input()
	a[i] += '#'
a.append('#' * (n + 2))
o = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		cnt = 0
		if a[i - 1][j] == 'o':
			cnt += 1
		if a[i][j - 1] == 'o':
			cnt += 1
		if a[i + 1][j] == 'o':
			cnt += 1
		if a[i][j + 1] == 'o':
			cnt += 1
		if cnt % 2 != 0:
			o = False
			break
	if o == False:
		break
if o:
	print('YES')
else:
	print('NO')


def simple_task(lst):
	for i in range(len(lst)):
		count = 0
		for j in range(len(lst)):
			if j > 0 and lst[i][j - 1] == 'o':
				count += 1
			if j < len(lst) - 1 and lst[i][j + 1] == 'o':
				count += 1
			if i > 0 and lst[i - 1][j] == 'o':
				count += 1
			if i < len(lst) - 1 and lst[i + 1][j] == 'o':
				count += 1
			if count & 1:
				return 'NO'
			count = 0
	return 'YES'
n = int(input())
z = list()
for i in range(n):
	s = input()
	z.append(list(s))
print(simple_task(z))


n = int(input())
c = []
for x in range(n):
	c.append(list(input()))
counter = 0
ruined = 0
for x in range(n):
	for y in range(n):
		counter = 0
		if x != 0 and c[x - 1][y] == 'o':
			counter += 1
		if x != n - 1 and c[x + 1][y] == 'o':
			counter += 1
		if y != 0 and c[x][y - 1] == 'o':
			counter += 1
		if y != n - 1 and c[x][y + 1] == 'o':
			counter += 1
		if counter % 2:
			ruined = 1
			break
if ruined:
	print('NO')
else:
	print('YES')


n = int(input())
count = 0
board = []
fail = False
while count < n:
	x = input()
	for letter in x:
		board.append(letter)
	count += 1
for i in range(n ** 2):
	total = 0
	if i - n < 0:
		pass
	elif board[i - n] == 'o':
		total += 1
	if i - 1 < 0:
		pass
	elif i % n == 0:
		pass
	elif board[i - 1] == 'o':
		total += 1
	if i + 1 > n ** 2 - 1:
		pass
	elif i % n == n - 1:
		pass
	elif board[i + 1] == 'o':
		total += 1
	if i + n > n ** 2 - 1:
		pass
	elif board[i + n] == 'o':
		total += 1
	if total % 2 == 1:
		fail = True
if fail == True:
	print('NO')
else:
	print('YES')


dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def inlims(x, y, n):
	return x >= 0 and y >= 0 and (x < n) and (y < n)
n = int(input())
mx = [input() for _ in range(n)]
flag = True
for x in range(n):
	for y in range(n):
		temp = [1 for i in range(4) if inlims(x + dx[i], y + dy[i], n) and mx[x + dx[i]][y + dy[i]] == 'o']
		if len(temp) % 2 != 0:
			flag = False
			break
	if not flag:
		break
print('YES' if flag else 'NO')


from collections import deque
from math import ceil, sqrt

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
n = ii()
a = []
for i in range(n):
	b = si()
	b = list(b)
	a.append(b)
f = 0
for i in range(n):
	for j in range(n):
		c = 0
		if i - 1 >= 0:
			if a[i - 1][j] == 'o':
				c += 1
		if j - 1 >= 0:
			if a[i][j - 1] == 'o':
				c += 1
		if i + 1 < n:
			if a[i + 1][j] == 'o':
				c += 1
		if j + 1 < n:
			if a[i][j + 1] == 'o':
				c += 1
		if c % 2:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print('NO')
else:
	print('YES')


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
nb_rows = read_int()
togather = ''
for _ in range(nb_rows):
	togather += input()
print(['NO', 'YES'][togather == togather[::-1]])


import os
import sys
from io import BytesIO, IOBase
import math as M
import itertools as ITR
from collections import defaultdict as D
from collections import Counter as C
from collections import deque as Q
import threading
from functools import lru_cache, reduce
from functools import cmp_to_key as CMP
from bisect import bisect_left as BL
from bisect import bisect_right as BR
import random as R
import string
import cmath, time
enum = enumerate
start_time = time.time()
MOD = 1000000007
MA = float('inf')
MI = float('-inf')
di8 = ((1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))
di4 = ((1, 0), (0, 1), (-1, 0), (0, -1))

def increase_stack():
	sys.setrecursionlimit(2 ** 32 // 2 - 1)
	threading.stack_size(1 << 27)

def binary(n):
	return bin(n)[2:]

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def maxfactor(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
	if q:
		return q[-1]

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	l.sort()
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def seive(n):
	a = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	prime[0] = prime[1] = False
	return (a, prime)

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(M.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countchar(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def str_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def lis(arr):
	n = len(arr)
	lis = [1] * n
	maximum = 0
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
				maximum = max(maximum, lis[i])
	return maximum

def lcm(arr):
	a = arr[0]
	val = arr[0]
	for i in range(1, len(arr)):
		gcd = gcd(a, arr[i])
		a = arr[i]
		val *= arr[i]
	return val // gcd

def ncr(n, r):
	return M.factorial(n) // (M.factorial(n - r) * M.factorial(r))

def npr(n, r):
	return M.factorial(n) // M.factorial(n - r)

def IF(c, t, f):
	return t if c else f

def YES(c):
	print(IF(c, 'YES', 'NO'))

def Yes(c):
	print(IF(c, 'Yes', 'No'))

def yes(c):
	print(IF(c, 'yes', 'no'))

def JA(a, sep=' '):
	print(sep.join(map(str, a)))

def JAA(a, s='\n', t=' '):
	return s.join((t.join(map(str, b)) for b in a))

def PS(a, s=' '):
	print(str(a), end=s)

def I():
	return int(inp())

def F():
	return float(inp())

def LI():
	return list(map(int, inp().split()))

def LF():
	return list(map(float, inp().split()))

def MATI(n):
	return [LI() for i in range(n)]

def MATS(n):
	return [list(inp()) for i in range(n)]

def IV():
	return map(int, inp().split())

def FV():
	return map(float, inp().split())

def LS():
	return list(inp())

def S():
	return inp()
BUFSIZE = 8192

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')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
TestCases = 0

def check(i, j, n, arr):
	co = 0
	for (x, y) in di4:
		ni = i + x
		nj = j + y
		if ni >= 0 and nj >= 0 and (ni < n) and (nj < n) and (arr[ni][nj] == 'o'):
			co += 1
	if co % 2 == 0:
		return True
	return False

def solve():
	n = I()
	arr = MATS(n)
	if n == 1:
		print('YES')
		return
	for i in range(n):
		for j in range(n):
			if not check(i, j, n, arr):
				print('NO')
				return
	print('YES')

def main():
	flag = 1
	try:
		sys.stdin = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/input.txt', 'r')
		sys.stdout = open('c:/Users/Manoj Chowdary/Documents/python/CodeForces/contest-div-2/output.txt', 'w')
	except:
		flag = 0
	t = 1
	if TestCases:
		t = I()
	for _ in range(1, t + 1):
		solve()
	if flag:
		print('Time: %.4f sec' % (time.time() - start_time))
		localtime = time.asctime(time.localtime(time.time()))
		print(localtime)
		sys.stdout.close()
main()


n = int(input())
l = []
flag = False
for i in range(n):
	s = input()
	l.append(list(s))
for i in range(n):
	for j in range(n):
		c = 0
		if i - 1 >= 0 and l[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and l[i + 1][j] == 'o':
			c += 1
		if j - 1 >= 0 and l[i][j - 1] == 'o':
			c += 1
		if j + 1 < n and l[i][j + 1] == 'o':
			c += 1
		if c & 1:
			flag = True
			break
if flag:
	print('NO')
else:
	print('YES')


n = int(input())
res = str()
for i in range(n):
	res += str(input())
if res == res[::-1]:
	print('YES')
else:
	print('NO')


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def li():
	return list(map(str, input()))
n = int(input())
l = [li() for _ in range(n)]
ch = 1
for i in range(n):
	for j in range(n):
		if l[i][j] == 'x' or l[i][j] == 'o':
			count = 0
			if i - 1 >= 0 and l[i - 1][j] == 'o':
				count += 1
			if j - 1 >= 0 and l[i][j - 1] == 'o':
				count += 1
			if i + 1 <= n - 1 and l[i + 1][j] == 'o':
				count += 1
			if j + 1 <= n - 1 and l[i][j + 1] == 'o':
				count += 1
			if count % 2:
				ch = 0
				print('NO')
				break
		if ch == 0:
			break
	if ch == 0:
		break
if ch:
	print('YES')


z = int(input())
c = 0
test = []
resu = True
for i in range(z):
	x = input()
	test.append(list(x))
if len(test) % 2 == 0:
	for i in range(z):
		if i >= z // 2:
			test[i].reverse()
	for i in range(z // 2):
		if test[i] != test[z - i - 1]:
			resu = False
			break
else:
	for i in range(z):
		if i >= z // 2 + 1:
			test[i].reverse()
	for i in range(z // 2):
		if i == z // 2:
			continue
		elif test[i] != test[z - i - 1]:
			resu = False
			break
if resu:
	print('YES')
else:
	print('NO')


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
mat = []
for i in range(n):
	mat.append(list(input()))
for i in range(n):
	for j in range(n):
		count = 0
		if i > 0 and mat[i - 1][j] == 'o':
			count += 1
		if j > 0 and mat[i][j - 1] == 'o':
			count += 1
		if i < n - 1 and mat[i + 1][j] == 'o':
			count += 1
		if j < n - 1 and mat[i][j + 1] == 'o':
			count += 1
		if count & 1:
			print('NO')
			exit()
print('YES')


def valid(i, j):
	return i >= 0 and j >= 0 and (i < n) and (j < n)
n = int(input())
arr = []
for i in range(0, n):
	arr.append(list(input()))
dr = [1, 0, -1, 0]
dc = [0, -1, 0, 1]
ans = 1
for i in range(0, n):
	for j in range(0, n):
		counter = 0
		for k in range(0, 4):
			x = i + dr[k]
			y = j + dc[k]
			if valid(x, y):
				counter += arr[x][y] == 'o'
		if counter % 2 == 1:
			ans = 0
			break
if ans:
	print('YES')
else:
	print('NO')


def giveResponse(mat, n):
	for i in range(1, n + 1):
		for j in range(1, n + 1):
			if (mat[i - 1][j] + mat[i + 1][j] + mat[i][j - 1] + mat[i][j + 1]) % 2 == 1:
				return 'NO'
	return 'YES'
mat = []
n = int(input())
mat = [[0] * (n + 2)]
for i in range(n):
	sat = [0]
	for j in input():
		if j == 'o':
			sat.append(1)
		else:
			sat.append(0)
	sat.append(0)
	mat.append(sat)
mat.append([0] * (n + 2))
print(giveResponse(mat, n))


n = int(input())
board = ['x' * (n + 2)] + ['x' + input() + 'x' for _ in range(n)] + ['x' * (n + 2)]
good = True
for i in range(1, n + 1):
	for j in range(1, n + 1):
		oneighbors = 0
		if board[i - 1][j] == 'o':
			oneighbors += 1
		if board[i + 1][j] == 'o':
			oneighbors += 1
		if board[i][j - 1] == 'o':
			oneighbors += 1
		if board[i][j + 1] == 'o':
			oneighbors += 1
		if oneighbors % 2 == 1:
			good = False
if good:
	print('YES')
else:
	print('NO')


n = int(input())
b = [[0 for i in range(n + 2)] for j in range(n + 2)]
for i in range(1, n + 1):
	s = input()
	for j in range(1, n + 1):
		if s[j - 1] == 'o':
			b[i - 1][j] += 1
			b[i + 1][j] += 1
			b[i][j + 1] += 1
			b[i][j - 1] += 1
yes = True
for i in range(1, n + 1):
	if not yes:
		break
	for j in range(1, n + 1):
		if b[i][j] % 2 == 1:
			print('NO')
			yes = False
			break
if yes:
	print('YES')


n = int(input())
matrix = []
matrix.append('x' * (n + 1))
for i in range(n):
	matrix.append('x' + input() + 'x')
matrix.append('x' * (n + 1))
count = 0
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if matrix[i - 1][j] == 'o':
			count += 1
		if matrix[i + 1][j] == 'o':
			count += 1
		if matrix[i][j - 1] == 'o':
			count += 1
		if matrix[i][j + 1] == 'o':
			count += 1
		if count % 2 == 1:
			print('NO')
			exit(0)
		count = 0
print('YES')


n = int(input())
desk = [input() for i in range(n)]
fl = True
for i in range(n):
	for g in range(n):
		a = 0
		if g - 1 >= 0:
			if desk[i][g - 1] == 'o':
				a += 1
		if g + 1 < n:
			if desk[i][g + 1] == 'o':
				a += 1
		if i - 1 >= 0:
			if desk[i - 1][g] == 'o':
				a += 1
		if i + 1 < n:
			if desk[i + 1][g] == 'o':
				a += 1
		if a % 2 != 0:
			fl = False
			break
	if not fl:
		print('NO')
		break
if fl:
	print('YES')


a = int(input())
b = []
for i in range(a):
	b += [input()]
d = False
for i in range(a):
	for j in range(a):
		c = 0
		if i > 0:
			c ^= b[i - 1][j] == 'o'
		if i < a - 1:
			c ^= b[i + 1][j] == 'o'
		if j > 0:
			c ^= b[i][j - 1] == 'o'
		if j < a - 1:
			c ^= b[i][j + 1] == 'o'
		if c % 2:
			d = True
			break
	if d:
		break
print('NO' if d else 'YES')


s = int(input())
b = []
for _ in range(s):
	b.append(input())
moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]
yes = True
for i in range(s):
	for j in range(s):
		cell = b[i][j]
		c = 0
		for move in moves:
			new_ij = [i + move[0], j + move[1]]
			if s > new_ij[0] >= 0 and s > new_ij[1] >= 0:
				new_cell = b[new_ij[0]][new_ij[1]]
				if new_cell == 'o':
					c += 1
		if c % 2 == 1:
			yes = False
print('YES' if yes else 'NO')


q = int(input())
from collections import defaultdict
d = defaultdict(lambda : 'x')
for i in range(q):
	for (j, value) in enumerate(input()):
		d[i, j] = value

def help_yablov():
	for i in range(q):
		for j in range(q):
			neigbours = [d[i, j - 1], d[i, j + 1], d[i - 1, j], d[i + 1, j]]
			if neigbours.count('o') % 2 == 1:
				print('NO')
				return
	print('YES')
help_yablov()


n = int(input())
desc = []
desc_num = []
for i in range(n):
	desc.append(input())
	desc_num.append([])
	for j in range(n):
		desc_num[i].append(0)
if n < 2:
	print('YES')
else:
	for line_num in range(1, n - 1):
		for letter_num in range(1, n - 1):
			if desc[line_num][letter_num] == 'o':
				desc_num[line_num + 1][letter_num] += 1
				desc_num[line_num - 1][letter_num] += 1
				desc_num[line_num][letter_num + 1] += 1
				desc_num[line_num][letter_num - 1] += 1
	for letter_num in range(1, n - 1):
		if desc[0][letter_num] == 'o':
			desc_num[1][letter_num] += 1
			desc_num[0][letter_num + 1] += 1
			desc_num[0][letter_num - 1] += 1
	for letter_num in range(1, n - 1):
		if desc[n - 1][letter_num] == 'o':
			desc_num[n - 2][letter_num] += 1
			desc_num[n - 1][letter_num + 1] += 1
			desc_num[n - 1][letter_num - 1] += 1
	for letter_num in range(1, n - 1):
		if desc[letter_num][0] == 'o':
			desc_num[letter_num][1] += 1
			desc_num[letter_num + 1][0] += 1
			desc_num[letter_num - 1][0] += 1
	for letter_num in range(1, n - 1):
		if desc[letter_num][n - 1] == 'o':
			desc_num[letter_num][n - 2] += 1
			desc_num[letter_num + 1][n - 1] += 1
			desc_num[letter_num - 1][n - 1] += 1
	if desc[0][0] == 'o':
		desc_num[1][0] += 1
		desc_num[0][1] += 1
	if desc[n - 1][0] == 'o':
		desc_num[n - 2][0] += 1
		desc_num[n - 1][1] += 1
	if desc[0][n - 1] == 'o':
		desc_num[1][n - 1] += 1
		desc_num[0][n - 2] += 1
	if desc[n - 1][n - 1] == 'o':
		desc_num[n - 1][n - 2] += 1
		desc_num[n - 2][n - 1] += 1
	i = j = 0
	while i < n and j < n and (desc_num[i][j] % 2 == 0):
		if i == n - 1:
			i = 0
			j += 1
		else:
			i += 1
	if i == 0 and j == n:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect

def solve(A):
	n = len(A)
	for i in range(n):
		for j in range(n):
			val = 0
			if i - 1 >= 0 and A[i - 1][j] == 'o':
				val += 1
			if j - 1 >= 0 and A[i][j - 1] == 'o':
				val += 1
			if i + 1 < n and A[i + 1][j] == 'o':
				val += 1
			if j + 1 < n and A[i][j + 1] == 'o':
				val += 1
			if val % 2 == 1:
				return False
	return True

def main():
	n = int(input())
	A = []
	for i in range(n):
		A.append(list(input()))
	if solve(A):
		print('YES')
	else:
		print('NO')
main()


n = int(input())
m = []
res = 0
for i in range(n):
	l = list(input())
	m.append(l)
for i in range(len(m)):
	if res != 0:
		break
	for j in range(len(m[i])):
		s = ''
		try:
			if i >= 0 and j - 1 >= 0:
				s += m[i][j - 1]
		except:
			pass
		try:
			if i >= 0 and j + 1 >= 0:
				s += m[i][j + 1]
		except:
			pass
		try:
			if i - 1 >= 0 and j >= 0:
				s += m[i - 1][j]
		except:
			pass
		try:
			if i + 1 >= 0 and j >= 0:
				s += m[i + 1][j]
		except:
			pass
		if s.count('o') % 2 != 0:
			print('NO')
			res += 1
			break
if res == 0:
	print('YES')


n = int(input())
m = []
for i in range(n):
	m.append(input())
for i in range(n):
	for j in range(n):
		c = 1 if i - 1 >= 0 and m[i - 1][j] == 'o' else 0
		c += 1 if j + 1 <= n - 1 and m[i][j + 1] == 'o' else 0
		c += 1 if i + 1 <= n - 1 and m[i + 1][j] == 'o' else 0
		c += 1 if j - 1 >= 0 and m[i][j - 1] == 'o' else 0
		if c % 2 == 1:
			print('NO')
			exit(0)
print('YES')


import math
from operator import itemgetter

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
n = int(input())
a = []
a.append(['b' for i in range(n + 2)])
for i in range(n):
	a.append(list('b' + input() + 'b'))
a.append(['b' for i in range(n + 2)])
for i in range(1, n + 1):
	for j in range(1, n + 1):
		cnt = 0
		if a[i - 1][j] == 'o':
			cnt += 1
		if a[i + 1][j] == 'o':
			cnt += 1
		if a[i][j - 1] == 'o':
			cnt += 1
		if a[i][j + 1] == 'o':
			cnt += 1
		if cnt % 2 != 0:
			print('NO')
			exit()
print('YES')


def positive_answer(A, n):
	for i in range(n):
		for j in range(n):
			if sum((0 <= x < n and 0 <= y < n and (A[x][y] == 'o') for (x, y) in ((i - 1, j), (i, j - 1), (i, j + 1), (i + 1, j)))) % 2:
				return False
	return True
n = int(input())
print('YES' if positive_answer([input() for _ in range(n)], n) else 'NO')


m = []
a = int(input())
for y in range(a):
	s_raw = input()
	r = []
	for x in range(a):
		if s_raw[x] == 'x':
			r += ['x']
		elif s_raw[x] == 'o':
			r += ['o']
	m += [r]
m_new = []
m_new += [['x'] * (a + 2)]
for y in range(a):
	r_new = ['x'] + m[y] + ['x']
	m_new += [r_new]
m_new += [['x'] * (a + 2)]
for y in range(1, a + 1):
	for x in range(1, a + 1):
		c = 0
		if m_new[x][y + 1] == 'o':
			c += 1
		if m_new[x][y - 1] == 'o':
			c += 1
		if m_new[x + 1][y] == 'o':
			c += 1
		if m_new[x - 1][y] == 'o':
			c += 1
		if c % 2 != 0:
			print('NO')
			quit()
print('YES')


from sys import *
n = int(input())
l = ['x' * (n + 2)] + ['x' + input() + 'x' for i in range(n)] + ['x' * (n + 2)]
for i in range(1, n + 1):
	for j in range(1, n + 1):
		k = 0
		if l[i + 1][j] == 'o':
			k += 1
		if l[i - 1][j] == 'o':
			k += 1
		if l[i][j + 1] == 'o':
			k += 1
		if l[i][j - 1] == 'o':
			k += 1
		if k % 2:
			print('NO')
			exit()
print('YES')


n = int(input())
answer = 'YES'
x = [0] * (n + 2)
for i in range(n):
	x[i + 1] = 'q' + input() + 'q'
x[0] = 'q' * (n + 2)
x[n + 1] = 'q' * (n + 2)
for i in range(1, n + 1):
	for j in range(1, n + 1):
		counter = 0
		if x[i][j + 1] == 'o':
			counter += 1
		if x[i][j - 1] == 'o':
			counter += 1
		if x[i + 1][j] == 'o':
			counter += 1
		if x[i - 1][j] == 'o':
			counter += 1
		if counter % 2 == 0:
			continue
		else:
			answer = 'NO'
			break
	if answer == 'NO':
		break
print(answer)


n = int(input())
e = ''
for i in range(n):
	s = str(input())
	e = e + s
if e == e[::-1]:
	print('YES')
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l1 = input()
	l.append(l1)
mark = 'YES'
for i in range(n):
	for j in range(n):
		s = int(0)
		if i + 1 < n:
			if l[i + 1][j] == 'o':
				s += 1
		if i - 1 >= 0:
			if l[i - 1][j] == 'o':
				s += 1
		if j + 1 < n:
			if l[i][j + 1] == 'o':
				s += 1
		if j - 1 >= 0:
			if l[i][j - 1] == 'o':
				s += 1
		if s % 2 != 0:
			mark = 'NO'
print(mark)


n = int(input())
l = []
for i in range(n):
	l.append(input())
flag = 0
for i in range(0, n):
	for k in range(0, n):
		count = 0
		if i - 1 >= 0:
			count += 1 if l[i - 1][k] == 'o' else 0
		if i + 1 < n:
			count += 1 if l[i + 1][k] == 'o' else 0
		if k + 1 < n:
			count += 1 if l[i][k + 1] == 'o' else 0
		if k - 1 >= 0:
			count += 1 if l[i][k - 1] == 'o' else 0
		if count % 2 != 0:
			flag = 1
			break
if flag == 1:
	print('NO')
else:
	print('YES')


n = int(input())
d = ['x' * (n + 2)]
for i in range(n):
	d.append('x' + input() + 'x')
d.append('x' * (n + 2))
ok = 1
for i in range(1, n + 1):
	for j in range(1, n + 1):
		nb = (d[i - 1][j] == 'o') + (d[i + 1][j] == 'o') + (d[i][j - 1] == 'o') + (d[i][j + 1] == 'o')
		if nb % 2 != 0:
			ok = 0
if ok == 1:
	print('YES')
else:
	print('NO')


N = int(input())
board = []
for i in range(N):
	board.append(input())
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
for i in range(N):
	for j in range(N):
		cnt = 0
		for d in range(4):
			ni = i + dx[d]
			nj = j + dy[d]
			if ni >= 0 and ni < N and (nj >= 0) and (nj < N):
				if board[ni][nj] == 'o':
					cnt += 1
		if cnt % 2 != 0:
			print('NO')
			exit()
print('YES')


import sys
import math
n = int(sys.stdin.readline())
varr = []
for i in range(n):
	varr.append([x for x in sys.stdin.readline()[:n]])
for i in range(n):
	val = 0
	for j in range(n):
		if j - 1 >= 0:
			val += 1 if varr[i][j - 1] == 'o' else 0
		if j + 1 < n:
			val += 1 if varr[i][j + 1] == 'o' else 0
		if i - 1 >= 0:
			val += 1 if varr[i - 1][j] == 'o' else 0
		if i + 1 < n:
			val += 1 if varr[i + 1][j] == 'o' else 0
		if val % 2 != 0:
			print('NO')
			exit()
		val = 0
print('YES')


n = int(input())
list1 = []
for i in range(n):
	ll = list(input())
	list1.append(ll)
list2 = []
for i in range(n):
	ll = [0] * n
	list2.append(ll)
for i in range(n):
	for j in range(n):
		if i > 0:
			if list1[i - 1][j] == 'o':
				list2[i][j] += 1
		if j > 0:
			if list1[i][j - 1] == 'o':
				list2[i][j] += 1
		if i < n - 1:
			if list1[i + 1][j] == 'o':
				list2[i][j] += 1
		if j < n - 1:
			if list1[i][j + 1] == 'o':
				list2[i][j] += 1
f = 0
for i in range(n):
	for j in range(n):
		if list2[i][j] % 2 != 0:
			f = 1
			break
if f == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = list()
for i in range(n):
	a.append(input())
x = y = 0
for i in range(n):
	for j in range(n):
		x = 0
		if n == 1:
			y = 2
			break
		elif i and j and (i != n - 1) and (j != n - 1):
			if a[i][j + 1] == 'o':
				x += 1
			if a[i][j - 1] == 'o':
				x += 1
			if a[i + 1][j] == 'o':
				x += 1
			if a[i - 1][j] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif i == 0 and j and (j != n - 1):
			if a[i][j - 1] == 'o':
				x += 1
			if a[i][j + 1] == 'o':
				x += 1
			if a[i + 1][j] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif i and j == 0 and (i != n - 1):
			if a[i + 1][j] == 'o':
				x += 1
			if a[i - 1][j] == 'o':
				x += 1
			if a[i][j + 1] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif i == 0 and j == 0:
			if a[i + 1][j] == 'o':
				x += 1
			if a[i][j + 1] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif i == n - 1 and j and (j != n - 1):
			if a[n - 1][j - 1] == 'o':
				x += 1
			if a[n - 1][j + 1] == 'o':
				x += 1
			if a[n - 2][j] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif j == n - 1 and i and (i != n - 1):
			if a[i + 1][j] == 'o':
				x += 1
			if a[i - 1][j] == 'o':
				x += 1
			if a[i][j - 1] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif j == 0 and i == n - 1:
			if a[i - 1][j] == 'o':
				x += 1
			if a[i][j + 1] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		elif i == 0 and j == n - 1:
			if a[i][j - 1] == 'o':
				x += 1
			if a[i + 1][j] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
		else:
			if a[i - 1][j] == 'o':
				x += 1
			if a[i][j - 1] == 'o':
				x += 1
			if x % 2:
				y = 1
				break
	if y:
		break
if y == 1:
	print('NO')
else:
	print('YES')


__author__ = 'Natik'
n = int(input())
mas = [[100] * n for i in range(n)]
for i in range(0, n):
	mas[i] = input()
ot = 0
for i in range(0, n):
	for j in range(0, n):
		klo = 0
		if j + 1 < n:
			if mas[i][j + 1] == 'o':
				klo += 1
		if i + 1 < n:
			if mas[i + 1][j] == 'o':
				klo += 1
		if i - 1 >= 0:
			if mas[i - 1][j] == 'o':
				klo += 1
		if j - 1 >= 0:
			if mas[i][j - 1] == 'o':
				klo += 1
		if klo % 2 == 1:
			ot = 1
if ot == 0:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
a = []
for i in range(n):
	a.append(input())
for i in range(n):
	for j in range(n):
		cnt = 0
		if i > 0 and a[i - 1][j] == 'o':
			cnt ^= 1
		if i + 1 < n and a[i + 1][j] == 'o':
			cnt ^= 1
		if j > 0 and a[i][j - 1] == 'o':
			cnt ^= 1
		if j + 1 < n and a[i][j + 1] == 'o':
			cnt ^= 1
		if cnt != 0:
			print('NO')
			sys.exit(0)
print('YES')


n = int(input())
board = ['0' * (n + 2)]
for i in range(n):
	row = input()
	board.append('0' + row + '0')
board.append('0' * (n + 2))
d = [(-1, 0), (1, 0), (0, 1), (0, -1)]
for i in range(1, n + 1):
	for j in range(1, n + 1):
		count = 0
		for (dx, dy) in d:
			if board[i + dx][j + dy] == 'o':
				count += 1
		if count % 2:
			print('NO')
			exit()
print('YES')


def main():
	n = int(input())
	grid = []
	for i in range(n):
		grid.append(list(input()))
	for i in range(n):
		for j in range(n):
			o = 0
			for (k, l) in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
				if i + k >= 0 and i + k < n and (j + l >= 0) and (j + l < n):
					if grid[i + k][j + l] == 'o':
						o += 1
			if o % 2 != 0:
				return 'NO'
	return 'YES'
print(main())


board = int(input())
game_board = []
game_board.append('#' * (board + 2))
for x in range(board):
	temp = input()
	temp = '#' + temp + '#'
	game_board.append(temp)
game_board.append('#' * (board + 2))
check = 0
num_os = 0
for x in range(1, board + 1):
	for y in range(1, board + 1):
		num_os = 0
		if game_board[x][y + 1] == 'o':
			num_os += 1
		if game_board[x][y - 1] == 'o':
			num_os += 1
		if game_board[x + 1][y] == 'o':
			num_os += 1
		if game_board[x - 1][y] == 'o':
			num_os += 1
		if num_os % 2 != 0:
			check = 1
			break
	if check == 1:
		break
if check == 1:
	print('NO')
else:
	print('YES')


from sys import stdin, stdout
input = stdin.readline

def putans():
	stdout.write(ans)
n = int(input())
brd = [input() for _ in range(n)]
ans = 'YES'
for i in range(n):
	for j in range(n):
		cnt = 0
		if i > 0:
			if brd[i - 1][j] == 'o':
				cnt += 1
		if i < n - 1:
			if brd[i + 1][j] == 'o':
				cnt += 1
		if j > 0:
			if brd[i][j - 1] == 'o':
				cnt += 1
		if j < n - 1:
			if brd[i][j + 1] == 'o':
				cnt += 1
		if cnt % 2 != 0:
			ans = 'NO'
			putans()
			exit(0)
putans()


n = int(input())
even_flag = True
checker = list()
for i in range(n):
	inp = input()
	checker.append(inp)
for i in range(n):
	c = 0
	for j in range(n):
		if i - 1 >= 0 and checker[i - 1][j] == 'o':
			c += 1
		if i + 1 < n and checker[i + 1][j] == 'o':
			c += 1
		if j - 1 >= 0 and checker[i][j - 1] == 'o':
			c += 1
		if j + 1 < n and checker[i][j + 1] == 'o':
			c += 1
		if c % 2 != 0:
			even_flag = False
			break
if even_flag:
	print('YES')
else:
	print('NO')


n = int(input())
cnt = 0
dirx = [0, 0, 1, -1]
diry = [1, -1, 0, 0]
ch = []

def valid_step(r, c):
	return r >= 0 and r < n and (c >= 0) and (c < n)
for i in range(n):
	ch.append(input())

def solve_o(n):
	for i in range(n):
		for g in range(n):
			cnt = 0
			for k in range(4):
				x = dirx[k] + i
				y = diry[k] + g
				if valid_step(x, y) and ch[x][y] == 'o':
					cnt += 1
			if cnt % 2 != 0:
				return 0
	return 1
print('YES') if solve_o(n) else print('NO')