A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares backward and 2 to the left. Naturally, the semiknight cannot move beyond the limits of the chessboard.

Petya put two semiknights on a standard chessboard. Petya simultaneously moves with both semiknights. The squares are rather large, so after some move the semiknights can meet, that is, they can end up in the same square. After the meeting the semiknights can move on, so it is possible that they meet again. Petya wonders if there is such sequence of moves when the semiknights meet. Petya considers some squares bad. That is, they do not suit for the meeting. The semiknights can move through these squares but their meetings in these squares don't count.

Petya prepared multiple chess boards. Help Petya find out whether the semiknights can meet on some good square for each board.

Please see the test case analysis.


-----Input-----

The first line contains number t (1 ≤ t ≤ 50) — the number of boards. Each board is described by a matrix of characters, consisting of 8 rows and 8 columns. The matrix consists of characters ".", "#", "K", representing an empty good square, a bad square and the semiknight's position, correspondingly. It is guaranteed that matrix contains exactly 2 semiknights. The semiknight's squares are considered good for the meeting. The tests are separated by empty line.


-----Output-----

For each test, print on a single line the answer to the problem: "YES", if the semiknights can meet and "NO" otherwise.


-----Examples-----
Input
2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K.......

........
........
..#.....
..#..#..
..####..
...##...
........
....K#K#

Output
YES
NO



-----Note-----

Consider the first board from the sample. We will assume the rows and columns of the matrix to be numbered 1 through 8 from top to bottom and from left to right, correspondingly. The knights can meet, for example, in square (2, 7). The semiknight from square (4, 1) goes to square (2, 3) and the semiknight goes from square (8, 1) to square (6, 3). Then both semiknights go to (4, 5) but this square is bad, so they move together to square (2, 7).

On the second board the semiknights will never meet.

Difficulty: MEDIUM
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
a = []

def first(i, j):
	nonlocal a
	a[i][j] = 1
	if i - 2 >= 0 and j + 2 < 8:
		a[i - 2][j + 2] = 1
	if i - 2 >= 0 and j - 2 >= 0:
		a[i - 2][j - 2] = 1
	if i + 2 < 8 and j + 2 < 8:
		a[i + 2][j + 2] = 1
	if i + 2 < 8 and j - 2 >= 0:
		a[i + 2][j - 2] = 1

def second(i, j):
	nonlocal a
	if a[i][j] == 1:
		return True
	if i - 2 >= 0 and j + 2 < 8:
		if a[i - 2][j + 2] == 1:
			return True
	if i - 2 >= 0 and j - 2 >= 0:
		if a[i - 2][j - 2] == 1:
			return True
	if i + 2 < 8 and j + 2 < 8:
		if a[i + 2][j + 2] == 1:
			return True
	if i + 2 < 8 and j - 2 >= 0:
		if a[i + 2][j - 2] == 1:
			return True
	return False
t = int(input())
for i in range(t):
	a = []
	exist = False
	for j in range(8):
		a.append(list(input()))
	d = 0
	for j in range(8):
		for k in range(8):
			if a[j][k] == 'K':
				d += 1
				if d == 1:
					first(j, k)
				elif d == 2:
					if second(j, k):
						exist = True
	if exist:
		print('YES')
	else:
		print('NO')
	if i != t - 1:
		input()


import sys
import collections

class GetOutOfLoop(Exception):
	pass
n_cases = int(sys.stdin.readline())
for case in range(n_cases):
	board = [list(sys.stdin.readline().rstrip()) for i in range(8)]
	knight_init_loc = [None, None]
	knight = 0
	for current_i in range(8):
		for current_j in range(8):
			if board[current_i][current_j] == 'K':
				knight_init_loc[knight] = (current_i, current_j)
				knight += 1
	to_explore = collections.deque()
	to_explore.append((knight_init_loc[0], 0))
	explored = set()
	try:
		while len(to_explore) > 0:
			((current_i, current_j), current_step) = to_explore.popleft()
			explored.add((current_i, current_j))
			candidates = set()
			for inc_i in [-2, 2]:
				for inc_j in [-2, 2]:
					(next_i, next_j) = (current_i + inc_i, current_j + inc_j)
					if 0 <= next_i < 8 and 0 <= next_j < 8 and ((next_i, next_j) not in explored):
						candidates.add(((next_i, next_j), current_step + 1))
			for (s, next_step) in candidates:
				if s == knight_init_loc[1] and next_step % 2 == 0:
					print('YES')
					raise GetOutOfLoop
				to_explore.append((s, next_step))
			current_step += 1
		print('NO')
	except GetOutOfLoop:
		pass
	sys.stdin.readline()


def main():
	n = int(input())
	out = ''
	for t in range(n):
		knights = [0 for i in range(16)]
		valid = [False for i in range(16)]
		for i in range(8):
			line = input()
			for j in range(8):
				if line[j] != '#':
					valid[get(i, j)] = True
				if line[j] == 'K':
					knights[get(i, j)] += 1
		for i in range(16):
			if knights[i] == 2 and valid[i]:
				out += 'YES\n'
				break
		else:
			out += 'NO\n'
		if t != n - 1:
			input()
	print(out[:-1])

def get(i, j):
	return [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]][i % 4][j % 4]

def __starting_point():
	main()
__starting_point()


t = int(input())
for k in range(t):
	r8 = range(8)
	a = [input() for i in r8]
	ij = [(i, j) for i in r8 for j in r8]
	(x, y) = ((i, j) for (i, j) in ij if a[i][j] == 'K')

	def s(p):
		d = [(p[0] - 2, p[1] - 2), (p[0] + 2, p[1] - 2), (p[0] - 2, p[1] + 2), (p[0] + 2, p[1] + 2)]
		return set(((i, j) for (i, j) in ij if (i, j) in d))
	print('YES' if len(s(x) & s(y)) > 0 else 'NO')
	if k != t - 1:
		input()


for i in range(int(input())):
	if i:
		input()
	ans = []
	for i in range(8):
		s = input()
		for j in range(8):
			if s[j] == 'K':
				ans.append((i, j))
	print(['NO', 'YES'][abs(ans[0][0] - ans[1][0]) % 4 == 0 and abs(ans[0][1] - ans[1][1]) % 4 == 0])


t = int(input())
for _ in range(t):
	s = [input() for i in range(8)]
	oh = True
	flag = True
	for i in range(8):
		for j in range(8):
			if s[i][j] == 'K':
				if flag:
					pos1x = i
					pos1y = j
					flag = False
				else:
					pos2x = i
					pos2y = j
	if pos1x % 4 == pos2x % 4 and pos1y % 4 == pos2y % 4:
		print('YES')
	else:
		print('NO')
	if _ < t - 1:
		k = input()


t = int(input())
for _ in range(t):
	if _:
		input()
	knights = []
	for i in range(8):
		s = input().strip()
		for j in range(8):
			if s[j] == 'K':
				knights.append((i, j))
	n1 = knights[0]
	n2 = knights[1]
	if n1[0] % 4 == n2[0] % 4 and n1[1] % 4 == n2[1] % 4:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	L = []
	for i in range(8):
		L.append(input())
	Moves1 = []
	Moves2 = []
	K = []
	for i in range(8):
		Moves1.append([-1] * 8)
		Moves2.append([-1] * 8)
		for j in range(8):
			if L[i][j] == 'K':
				K.append((i, j))
	Now = K[0]
	Explored = [(Now[0], Now[1], 0)]
	Moves1[Now[0]][Now[1]] = 0
	while len(Explored) != 0:
		x = Explored[0][0]
		y = Explored[0][1]
		p = Explored[0][2]
		Explored.pop(0)
		if x - 2 >= 0 and y - 2 >= 0:
			if Moves1[x - 2][y - 2] == -1:
				Moves1[x - 2][y - 2] = 1 - p
				Explored.append((x - 2, y - 2, 1 - p))
		if x + 2 < 8 and y - 2 >= 0:
			if Moves1[x + 2][y - 2] == -1:
				Moves1[x + 2][y - 2] = 1 - p
				Explored.append((x + 2, y - 2, 1 - p))
		if x - 2 >= 0 and y + 2 < 8:
			if Moves1[x - 2][y + 2] == -1:
				Moves1[x - 2][y + 2] = 1 - p
				Explored.append((x - 2, y + 2, 1 - p))
		if x + 2 < 8 and y + 2 < 8:
			if Moves1[x + 2][y + 2] == -1:
				Moves1[x + 2][y + 2] = 1 - p
				Explored.append((x + 2, y + 2, 1 - p))
	Now = K[1]
	Explored = [(Now[0], Now[1], 0)]
	Moves2[Now[0]][Now[1]] = 0
	while len(Explored) != 0:
		x = Explored[0][0]
		y = Explored[0][1]
		p = Explored[0][2]
		Explored.pop(0)
		if x - 2 >= 0 and y - 2 >= 0:
			if Moves2[x - 2][y - 2] == -1:
				Moves2[x - 2][y - 2] = 1 - p
				Explored.append((x - 2, y - 2, 1 - p))
		if x + 2 < 8 and y - 2 >= 0:
			if Moves2[x + 2][y - 2] == -1:
				Moves2[x + 2][y - 2] = 1 - p
				Explored.append((x + 2, y - 2, 1 - p))
		if x - 2 >= 0 and y + 2 < 8:
			if Moves2[x - 2][y + 2] == -1:
				Moves2[x - 2][y + 2] = 1 - p
				Explored.append((x - 2, y + 2, 1 - p))
		if x + 2 < 8 and y + 2 < 8:
			if Moves2[x + 2][y + 2] == -1:
				Moves2[x + 2][y + 2] = 1 - p
				Explored.append((x + 2, y + 2, 1 - p))
	valid = False
	for i in range(8):
		for j in range(8):
			if Moves1[i][j] != -1 and Moves1[i][j] == Moves2[i][j] and (L[i][j] != '#'):
				valid = True
	if valid:
		print('YES')
	else:
		print('NO')
	if t != T - 1:
		s = input()


3
n = int(input())
for _ in range(n):
	k = []
	b = []
	for i in range(8):
		s = input()
		for j in range(8):
			if s[j] == 'K':
				k.append((i, j))
	print('YES' if abs(k[0][0] - k[1][0]) % 4 == 0 and abs(k[0][1] - k[1][1]) % 4 == 0 else 'NO')
	if _ < n - 1:
		input()


t = int(input())
for _ in range(t):
	if _ != 0:
		tmp = input()
	pos = []
	n = 8
	g = []
	for i in range(n):
		g.append([i for i in input()])
	for i in range(n):
		for j in range(n):
			if g[i][j] == 'K':
				pos.append((i, j))
	ok = False
	for i in range(n):
		for j in range(n):
			if i % 2 == pos[0][0] % 2 and i % 2 == pos[1][0] % 2 and (j % 2 == pos[0][1] % 2) and (j % 2 == pos[1][1] % 2):
				dist1 = (i - pos[0][0], j - pos[0][1])
				dist2 = (i - pos[1][0], j - pos[1][1])
				if dist1[0] - dist2[0] % 4 == 0 and dist1[1] - dist2[1] % 4 == 0:
					ok = True
	print('YES' if ok else 'NO')


N = range(8)
test = int(input())
for i_test in range(test):
	if i_test:
		input()
	(x1, y1, x2, y2) = (0, 0, 0, 0)
	map = [input() for i in N]
	for i in N:
		for j in N:
			if map[i][j] == 'K':
				(x1, y1, x2, y2) = (x2, y2, i, j)
	if abs(x1 - x2) % 4 == 0 and abs(y1 - y2) % 4 == 0:
		print('YES')
	else:
		print('NO')


import collections
n = list(map(int, input().split()))[0]
di = ((2, 2), (-2, 2), (-2, -2), (2, -2))

def bfs(graph, x, y, tx, ty):
	vis = set()
	queue = collections.deque()
	queue.append((x, y))
	vis.add((x, y))
	dis = {}
	dis[x, y] = 0
	while queue:
		elem = queue.popleft()
		for direction in di:
			new_elem = (elem[0] + direction[0], elem[1] + direction[1])
			if new_elem[0] >= 0 and new_elem[1] >= 0 and (new_elem[0] < 8) and (new_elem[1] < 8):
				if new_elem not in vis:
					vis.add(new_elem)
					queue.append(new_elem)
					dis[new_elem] = dis[elem] + 1
	if (tx, ty) not in vis:
		return (False, 0)
	return (True, dis[tx, ty])
for cc in range(n):
	datamap = []
	for i in range(8):
		datamap.append(input())
	ans = []
	for i in range(len(datamap)):
		for j in range(len(datamap[i])):
			if datamap[i][j] == 'K':
				ans.append(i)
				ans.append(j)
	ans = bfs(datamap, ans[0], ans[1], ans[2], ans[3])
	if ans[0] and ans[1] % 2 == 0:
		print('YES')
	else:
		print('NO')
	if cc != n - 1:
		input()


t = int(input())
el = [[1, 2, 3, 4, 1, 2, 3, 4], [5, 6, 7, 8, 5, 6, 7, 8], [9, 10, 11, 12, 9, 10, 11, 12], [13, 14, 15, 16, 13, 14, 15, 16], [1, 2, 3, 4, 1, 2, 3, 4], [5, 6, 7, 8, 5, 6, 7, 8], [9, 10, 11, 12, 9, 10, 11, 12], [13, 14, 15, 16, 13, 14, 15, 16]]
for x in range(t):
	arr = [[] for i in range(8)]
	for i in range(8):
		s = input()
		for j in range(len(s)):
			arr[i].append(s[j])
	l = 0
	for i in range(8):
		for j in range(8):
			if l == 0:
				if arr[i][j] == 'K':
					k1 = el[i][j]
					l = 1
			elif arr[i][j] == 'K':
				k2 = el[i][j]
				break
	if k1 == k2:
		print('YES')
	else:
		print('NO')
	if x != t - 1:
		y = list(map(int, input().split()))


n = int(input())
for t in range(n):
	if t:
		input()
	board = [[c for c in input()] for i in range(8)]
	(k1, k2) = ((i, j) for i in range(8) for j in range(8) if board[i][j] == 'K')
	if (k1[0] - k2[0]) % 4 == 0 and (k1[1] - k2[1]) % 4 == 0:
		print('YES')
	else:
		print('NO')


def f():
	t = []
	for i in range(8):
		p = input()
		for j in range(8):
			if p[j] == 'K':
				t += [i, j]
	if t[2] - t[0] in (0, 4) and t[1] - t[3] in (-4, 0, 4):
		return 'YES'
	return 'NO'
for i in range(int(input()) - 1):
	print(f())
	input()
print(f())


n = int(input())
for i in range(n):
	if i:
		input()
	x1 = y1 = x2 = y2 = 0
	s = [input() for i in range(8)]
	for i in range(8):
		for j in range(8):
			if s[i][j] == 'K':
				(x1, y1, x2, y2) = (x2, y2, i, j)
	if abs(x1 - x2) % 4 == 0 and abs(y1 - y2) % 4 == 0:
		print('YES')
	else:
		print('NO')


def check(x, y):
	return 0 <= x < 8 and 0 <= y < 8

def dfs1(x, y, T=0):
	nonlocal first, used
	if not check(x, y) or used[x][y]:
		return
	used[x][y] = True
	first.add((x, y, T))
	for pair in ((2, 2), (2, -2), (-2, 2), (-2, -2)):
		dfs1(x + pair[0], y + pair[1], 1 - T)

def dfs2(x, y, T=0):
	nonlocal second, used
	if not check(x, y) or used[x][y]:
		return
	used[x][y] = True
	second.add((x, y, T))
	for pair in ((2, 2), (2, -2), (-2, 2), (-2, -2)):
		dfs2(x + pair[0], y + pair[1], 1 - T)
t = int(input())
for i in range(t):
	if i > 0:
		kuzma = input()
	board = [input() for i in range(8)]
	FoundFirst = False
	for i in range(8):
		for j in range(8):
			if board[i][j] == 'K':
				if not FoundFirst:
					First = (i, j)
					FoundFirst = True
				else:
					Second = (i, j)
	used = [[0 for i in range(8)] for j in range(8)]
	first = set()
	dfs1(First[0], First[1])
	used = [[0 for i in range(8)] for j in range(8)]
	second = set()
	dfs2(Second[0], Second[1])
	intersection = first & second
	IsOk = False
	for (x, y, t) in intersection:
		if board[x][y] != '#':
			print('YES')
			IsOk = True
			break
	if not IsOk:
		print('NO')
	board = []


t = int(input())
while t:
	t += -1
	l = []
	mp = []
	for i in range(8):
		tmp = list(input())
		l.append(tmp)
		mp.append([0] * 8)
	(i1, j1, i2, j2) = (-1, -1, -1, -1)
	for i in range(8):
		for j in range(8):
			if l[i][j] == 'K' and i1 == -1:
				(i1, j1) = (i, j)
			if l[i][j] == 'K':
				(i2, j2) = (i, j)
	if abs(i2 - i1) % 4 == 0 and abs(j2 - j1) % 4 == 0:
		print('YES')
	else:
		print('NO')
	if t != 0:
		input()


import sys
import math
import collections
import heapq
t = int(input())
for w in range(t):
	l = []
	for i in range(8):
		l1 = list(input())
		l.append(l1)
	(t1, t2) = ((), ())
	for i in range(8):
		for j in range(8):
			if l[i][j] == 'K':
				if t1 == ():
					t1 = (i, j)
				else:
					t2 = (i, j)
					break
		if t2 != ():
			break
	if (t1[0] - t2[0]) % 4 == 0 and (t1[1] - t2[1]) % 4 == 0:
		print('YES')
	else:
		print('NO')
	if w < t - 1:
		input()


N = int(input())
for i in range(N):
	if i > 0:
		input()
	Pos = []
	for i in range(8):
		S = input().strip()
		for j in range(8):
			if S[j] == 'K':
				Pos.append((i, j))
	(Dx, Dy) = (abs(Pos[0][0] - Pos[1][0]), abs(Pos[0][1] - Pos[1][1]))
	if (Dx == 0 or Dx == 4) and (Dy == 0 or Dy == 4):
		print('YES')
	else:
		print('NO')


import os
import sys
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')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
from collections import deque

def dfs(graph, alpha=0):
	n = len(graph)
	q = deque([alpha])
	used = [False] * n
	used[alpha] = True
	(dist, parents) = ([0] * n, [-1] * n)
	while q:
		v = q.popleft()
		for u in graph[v]:
			if not used[u]:
				used[u] = True
				q.append(u)
				dist[u] = dist[v] + 1
				parents[u] = v
	return (used, dist)
for _ in range(int(input()) if True else 1):
	a = []

	def pos(i, j):
		return i * 8 + j + 1
	for i in range(8):
		a += [[k for k in input()]]
	graph = [[] for i in range(65)]
	ks = []
	for i in range(8):
		for j in range(8):
			if a[i][j] == 'K':
				ks += [pos(i, j)]
			if 1:
				if i + 2 < 8:
					if 0 <= j + 2 < 8:
						graph[pos(i, j)] += [pos(i + 2, j + 2)]
						graph[pos(i + 2, j + 2)] += [pos(i, j)]
					if 0 <= j - 2 < 8:
						graph[pos(i, j)] += [pos(i + 2, j - 2)]
						graph[pos(i + 2, j - 2)] += [pos(i, j)]
				if 0 <= i - 2 < 8:
					if 0 <= j + 2 < 8:
						graph[pos(i, j)] += [pos(i - 2, j + 2)]
						graph[pos(i - 2, j + 2)] += [pos(i, j)]
					if 0 <= j - 2 < 8:
						graph[pos(i, j)] += [pos(i - 2, j - 2)]
						graph[pos(i - 2, j - 2)] += [pos(i, j)]
	(d1, dist1) = dfs(graph, ks[0])
	(d2, dist2) = dfs(graph, ks[1])
	found = False
	for i in range(1, len(d1)):
		if d1[i] and d2[i] and (dist1[i] == dist2[i]):
			print('YES')
			found = True
			break
	if not found:
		print('NO')
	x = input()


def check():
	board = []
	for cont in range(0, 8):
		board.append(input())
	l = True
	for cont in range(0, 8):
		for cont2 in range(0, 8):
			if board[cont][cont2] == 'K':
				if l:
					xk1 = cont2
					yk1 = cont
					l = False
				else:
					xk2 = cont2
					yk2 = cont
					break
	for cont in range(0, 8):
		for cont2 in range(0, 8):
			if cont2 % 2 == xk1 % 2 == xk2 % 2:
				if cont % 2 == yk1 % 2 == yk2 % 2:
					if abs(cont2 - xk1) % 4 == abs(cont2 - xk2) % 4:
						if abs(cont - yk1) % 4 == abs(cont - yk2) % 4:
							if board[cont][cont2] != '#':
								print('YES')
								return
	print('NO')
	return
n = int(input())
check()
for t in range(0, n - 1):
	a = str(input())
	check()


MOVS = [(2, -2), (-2, 2), (-2, -2), (2, 2)]

def check(a):
	return 0 <= a < 8
set1 = set()
set2 = set()
dic1 = dict()
dic2 = dict()

def cango1(matrix, pos, lap):
	for (dx, dy) in MOVS:
		(nx, ny) = (dx + pos[0], dy + pos[1])
		if not check(nx) or not check(ny):
			continue
		if (nx, ny) in set1:
			continue
		dic1[nx, ny] = lap % 2
		set1.add((nx, ny))
		cango1(matrix, (nx, ny), lap + 1)

def cango2(matrix, pos, lap):
	for (dx, dy) in MOVS:
		(nx, ny) = (dx + pos[0], dy + pos[1])
		if not check(nx) or not check(ny):
			continue
		if (nx, ny) in set2:
			continue
		dic2[nx, ny] = lap % 2
		set2.add((nx, ny))
		cango2(matrix, (nx, ny), lap + 1)
q = int(input())
for ww in range(q):
	matrix = [input().strip() for i in range(8)]
	pos = []
	bad = set()
	for i in range(8):
		for j in range(8):
			if matrix[i][j] == 'K':
				pos.append((i, j))
			if matrix[i][j] == '#':
				bad.add((i, j))
	(set1, set2, dic1, dic2) = (set(), set(), dict(), dict())
	cango1(matrix, pos[0], 0)
	cango2(matrix, pos[1], 0)
	if ww != q - 1:
		input()
	sec = (set1 & set2) - bad
	for (x, y) in sec:
		if dic1[x, y] == dic2[x, y]:
			print('YES')
			break
	else:
		print('NO')


def solve(m, x, y, w, z):
	for i in range(8):
		for j in range(8):
			if m[i][j]:
				(a, pa) = movePossible(x, y, i, j)
				(b, pb) = movePossible(w, z, i, j)
				if a and b and (pa == pb):
					return True
	return False

def movePossible(x, y, w, z):
	a = x - w
	b = y - z
	pos = False
	ka = a // 2
	kb = b // 2
	if a % 2 == 0 and b % 2 == 0 and ((ka + kb) % 2 == 0):
		pos = True
	return (pos, ka % 2)
t = int(input())
for _c in range(t):
	m = []
	primo = True
	for i in range(8):
		m.append([])
		s = input()
		k = 0
		for c in s:
			if c == '#':
				m[i].append(False)
			else:
				m[i].append(True)
			if c == 'K' and primo:
				x = i
				y = k
				primo = False
			if c == 'K' and (not primo):
				w = i
				z = k
			k += 1
	if solve(m, x, y, w, z):
		print('YES')
	else:
		print('NO')
	if _c != t - 1:
		m = input()