Chef develops his own computer program for playing chess. He is at the very beginning. At first he needs to write the module that will receive moves written by the players and analyze it. The module will receive a string and it should report at first whether this string represents the correct pair of cells on the chess board (we call such strings correct) and then report whether it represents the correct move depending on the situation on the chess board. Chef always has troubles with analyzing knight moves. So at first he needs a test program that can say whether a given string is correct and then whether it represents a correct knight move (irregardless of the situation on the chess board). The cell on the chessboard is represented as a string of two characters: first character is a lowercase Latin letter from a to h and the second character is a digit from 1 to 8. The string represents the correct pair of cells on the chess board if it composed of 5 characters where first two characters represent the cell where chess figure was, 3rd character is the dash "-" and the last two characters represent the destination cell.

------ Input ------ 

The first line contains a single integer T ≤ 50000, the number of test cases. T test cases follow. The only line of each test case contains a non-empty string composed the characters with ASCII-codes from 32 to 126. The length of the string is not greater than 10.

------ Output ------ 

For each test case, output a single line containing the word "Error" if the corresponding string does not represent the correct pair of cells on the chess board. Otherwise output "Yes" if this pair of cells represents the correct knight move and "No" otherwise.

----- Sample Input 1 ------ 
4
a1-b3
d2-h8
a3 c4
ErrorError
----- Sample Output 1 ------ 
Yes
No
Error
Error

Source: codechef | Difficulty: MEDIUM
Tags: String algorithms

Data structures

Implementation


Solutions:
def move(mv):
	err = 'Error'
	no = 'No'
	yes = 'Yes'
	if len(mv) != 5:
		return err
	elif (mv[0] < 'a' or mv[0] > 'h') or (mv[1] < '1' or mv[1] > '8') or mv[2] != '-' or (mv[3] < 'a' or mv[3] > 'h') or (mv[4] < '1' or mv[4] > '8'):
		return err
	else:
		c1 = ord(mv[0])
		c2 = ord(mv[3])
		d1 = int(mv[1])
		d2 = int(mv[4])
		if abs((c1 - c2) * (d1 - d2)) == 2:
			return yes
		else:
			return no
tc = int(input())
for _ in range(tc):
	s = input()
	print(move(s))


import sys
input = sys.stdin.readline

def rii():
	return range(int(input().strip()))

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

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())
import re
regex = '^([a-h])([1-8])\\-([a-h])([1-8])$'

def column(c):
	return ord(c) - 96

def solve(mv):
	r = re.findall(regex, mv)
	if len(r) == 0:
		return 'Error'
	(fc, fr, tc, tr) = r[0]
	col_diff = abs(column(fc) - column(tc))
	row_diff = abs(int(fr) - int(tr))
	if col_diff > row_diff:
		(col_diff, row_diff) = (row_diff, col_diff)
	if (col_diff, row_diff) == (1, 2):
		return 'Yes'
	else:
		return 'No'

def do_codechef():
	for t in rii():
		print(solve(input()))
do_codechef()
exit()


a = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
b = ('1', '2', '3', '4', '5', '6', '7', '8')
for case in range(int(input())):
	s = input()
	if len(s) == 5 and s[0] in a and (s[1] in b) and (s[2] == '-') and (s[3] in a) and (s[4] in b):
		if abs(ord(s[0]) - ord(s[3])) == 1 and abs(ord(s[1]) - ord(s[4])) == 2 or (abs(ord(s[0]) - ord(s[3])) == 2 and abs(ord(s[1]) - ord(s[4])) == 1):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


def Solve(s, n):
	if len(s) != 5 or s.count('-') != 1:
		return 'Error'
	(start, destination) = s.split('-')
	if len(start) != 2 or len(destination) != 2:
		return 'Error'
	if ord('a') <= ord(start[0]) <= ord('h') and ord('a') <= ord(destination[0]) <= ord('h') and (ord('1') <= ord(start[1]) <= ord('8')) and (ord('1') <= ord(destination[1]) <= ord('8')):
		diff1 = abs(ord(start[0]) - ord(destination[0]))
		diff2 = abs(ord(start[1]) - ord(destination[1]))
		if diff1 == 1 and diff2 == 2 or (diff1 == 2 and diff2 == 1):
			return 'Yes'
		return 'No'
	return 'Error'
for _ in range(int(input())):
	s = input()
	print(Solve(s, len(s)))


t = int(input())
for i in range(t):
	s = input()
	if len(s) == 5 and s[2] == '-' and (s[0] in 'abcdefgh') and (s[3] in 'abcdefgh') and (s[1] in '12345678') and (s[4] in '12345678'):
		if abs(ord(s[0]) - ord(s[3])) == 2 and abs(int(s[1]) - int(s[4])) == 1 or (abs(ord(s[0]) - ord(s[3])) == 1 and abs(int(s[1]) - int(s[4])) == 2):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


row = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
col = ['1', '2', '3', '4', '5', '6', '7', '8']
dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
move = [(-2, -1), (-2, 1), (2, -1), (2, 1), (-1, 2), (1, 2), (-1, -2), (1, -2)]

def move_path(x, y):
	path = []
	for m in move:
		co = y + m[0]
		ro = x + m[1]
		if co > 0 and co < 9 and (ro > 0) and (ro < 9):
			path += [[ro, co]]
	return path
for _ in range(int(input())):
	inn = input()
	err = 0
	if len(inn) != 5:
		err = 1
	else:
		(a, b, c, d, e) = list(inn)
		if a not in row or d not in row:
			err = 1
		elif c != '-':
			err = 1
		elif b not in col or e not in col:
			err = 1
	if not err:
		aa = dic.get(a)
		dd = dic.get(d)
		next = move_path(aa, int(b))
		next_in = [dd, int(e)]
		print('Yes' if next_in in next else 'No')
	else:
		print('Error')


for _ in range(int(input())):
	s = list(input())
	if len(s) == 5:
		flag = 0
		for i in range(5):
			try:
				ord(s[i])
			except:
				flag = 1
				break
		if flag == 1:
			print('Error')
			continue
		if (ord(s[0]) >= 97 and ord(s[0]) <= 104) and (ord(s[1]) >= 49 and ord(s[1]) <= 56) and (ord(s[2]) == 45) and (ord(s[3]) >= 97 and ord(s[3]) <= 104) and (ord(s[4]) >= 49 and ord(s[4]) <= 56):
			if abs(ord(s[0]) - ord(s[3])) == 1 and abs(ord(s[1]) - ord(s[4])) == 2 or (abs(ord(s[0]) - ord(s[3])) == 2 and abs(ord(s[1]) - ord(s[4])) == 1):
				print('Yes')
			else:
				print('No')
		else:
			print('Error')
	else:
		print('Error')


__author__ = 'Ronald Kaiser'
__email__ = 'raios dot catodicos at gmail dot com'
for _ in range(int(input())):
	s = input()
	if len(s) != 5:
		print('Error')
		continue
	(sc, sr, dc, dr) = (ord(s[0]) - 97, ord(s[1]) - 48, ord(s[3]) - 97, ord(s[4]) - 48)
	if not (s[2] == '-' and sc in range(0, 8) and (sr in range(1, 9)) and (dc in range(0, 8)) and (dr in range(1, 9))):
		print('Error')
		continue
	if dc == sc - 1 and (dr == sr + 2 or dr == sr - 2) or (dc == sc + 1 and (dr == sr + 2 or dr == sr - 2)) or (dc == sc - 2 and (dr == sr - 1 or dr == sr + 1)) or (dc == sc + 2 and (dr == sr - 1 or dr == sr + 1)):
		print('Yes')
	else:
		print('No')


d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
for _ in range(int(input())):
	a = input()
	try:
		if len(a) == 5 and a[0] in d and (a[1] in '12345678') and (a[2] == '-') and (a[3] in d) and (a[4] in '12345678'):
			y = [-2, -2, 2, 2, -1, 1, -1, 1]
			x = [1, -1, 1, -1, 2, 2, -2, -2]
			i = int(a[1])
			j = d[a[0]]
			p = int(a[4])
			q = d[a[3]]
			for k in range(len(x)):
				if i + x[k] == p and j + y[k] == q:
					print('Yes')
					break
			else:
				print('No')
		else:
			print('Error')
	except:
		print('Error')


for i in range(int(input())):
	s = input()
	if len(s) != 5 or s[2] != '-':
		print('Error')
	elif (s[0] >= 'a' and s[0] <= 'h') and (s[3] >= 'a' and s[3] <= 'h') and (s[1] >= '1' and s[1] <= '8') and (s[4] >= '1' and s[4] <= '8'):
		if abs(ord(s[0]) - ord(s[3])) * abs(ord(s[4]) - ord(s[1])) == 2:
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


def main():
	from re import fullmatch
	testCases = int(input())
	while testCases:
		string = input()
		match = fullmatch('[a-h][1-8]-[a-h][1-8]', string)
		XandYshift = [(-1, -2), (1, -2), (-2, -1), (2, -1), (-2, 1), (2, 1), (-1, 2), (1, 2)]
		if match != None:
			flag = -1
			currentPosition = (ord(string[0]) - 96, int(string[1]))
			destinationPosition = (ord(string[3]) - 96, int(string[4]))
			for index in XandYshift:
				posAfterShift = (currentPosition[0] + index[0], currentPosition[1] + index[1])
				if posAfterShift == destinationPosition:
					print('Yes')
					flag = 0
					break
			if flag == -1:
				print('No')
		else:
			print('Error')
		testCases -= 1
main()


(ch, dg) = ('abcdefgh', '12345678')
ans = []
for _ in range(int(input())):
	A = input()
	if len(A) != 5:
		an = 'Error'
	elif A[0] not in ch or A[3] not in ch or A[1] not in dg or (A[4] not in dg) or (A[2] != '-'):
		an = 'Error'
	else:
		(c, d) = (abs(ord(A[0]) - ord(A[3])), abs(int(A[1]) - int(A[4])))
		if c != 0 and d != 0 and (c + d == 3):
			an = 'Yes'
		else:
			an = 'No'
	ans.append(an)
print(*ans, sep='\n')


def diff(x, y):
	return abs(ord(x) - ord(y))

def isValid(x):
	if len(x) == 5:
		if x[0] in 'abcdefgh' and x[1] in '12345678' and (x[2] == '-') and (x[3] in 'abcdefgh') and (x[4] in '12345678'):
			return 1
	return 0

def fun(x):
	if isValid(x) == 1:
		if diff(x[0], x[3]) == 1 and diff(x[1], x[4]) == 2 or (diff(x[0], x[3]) == 2 and diff(x[1], x[4]) == 1):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')
t = int(input(''))
for i in range(t):
	x = input()
	fun(x)


tests = int(input())
for i in range(tests):
	string = input()
	ans = 'No'
	if not (len(string) == 5 and 97 <= ord(string[0]) <= 104 and (49 <= ord(string[1]) <= 56) and (string[2] == '-') and (97 <= ord(string[3]) <= 104) and (49 <= ord(string[4]) <= 56)):
		ans = 'Error'
	else:
		start_x = ord(string[0])
		start_y = int(string[1])
		end_x = ord(string[3])
		end_y = int(string[4])
		if start_x + 2 == end_x and (end_y == start_y + 1 or end_y == start_y - 1) or (start_x - 2 == end_x and (end_y == start_y + 1 or end_y == start_y - 1)) or (start_x + 1 == end_x and (end_y == start_y + 2 or end_y == start_y - 2)) or (start_x - 1 == end_x and (end_y == start_y + 2 or end_y == start_y - 2)):
			ans = 'Yes'
	print(ans)


from sys import stdin as sin

def aint():
	return int(input())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return input()
for _ in range(int(input())):
	s = astr()
	if len(s) == 5 and ord(s[0]) in range(97, 105) and (ord(s[3]) in range(97, 105)) and (ord(s[1]) in range(49, 57)) and (ord(s[4]) in range(49, 57)) and (int(s[1]) in range(1, 9)) and (int(s[4]) in range(1, 9)) and (s[2] == '-'):
		if abs(ord(s[3]) - ord(s[0])) == 1 and abs(int(s[1]) - int(s[4])) == 2 or (abs(ord(s[3]) - ord(s[0])) == 2 and abs(int(s[1]) - int(s[4])) == 1):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


colConv = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
col = set(list('abcdefgh'))
row = set(list('12345678'))
for _ in range(int(input())):
	m = input()
	if len(m) != 5:
		print('Error')
		continue
	if m[2] != '-' or m[0] not in col or m[3] not in col or (m[1] not in row) or (m[4] not in row):
		print('Error')
		continue
	(x1, y1, x2, y2) = (colConv[m[0]], int(m[1]), colConv[m[3]], int(m[4]))
	if abs(x1 - x2) == 2 and abs(y1 - y2) == 1 or (abs(x1 - x2) == 1 and abs(y1 - y2) == 2):
		print('Yes')
	else:
		print('No')


def valid_cell(a, b):
	return a >= 97 and a <= 104 and (b >= 49) and (b <= 56)

def valid_move(a, b, c, d):
	diffA = abs(c - a)
	diffB = abs(d - b)
	if diffA == 2 and diffB == 1 or (diffB == 2 and diffA == 1):
		return True
	else:
		return False
for _ in range(int(input())):
	string = input()
	if len(string) != 5 or string[2] != '-':
		print('Error')
		continue
	else:
		cell = string.split('-')
		if len(cell) == 2:
			a = ord(cell[0][0])
			b = ord(cell[0][1])
			c = ord(cell[1][0])
			d = ord(cell[1][1])
		else:
			print('Error')
			continue
		if valid_cell(a, b) and valid_cell(c, d):
			if valid_move(a, b, c, d):
				print('Yes')
			else:
				print('No')
		else:
			print('Error')


for _ in range(int(input())):
	s = input()
	f = True
	if len(s) == 5:
		q = 'abcdefgh'
		n = '12345678'
		if s[0] in q and s[3] in q and (s[1] in n) and (s[4] in n) and (s[2] == '-'):
			pass
		else:
			f = False
	else:
		f = False
	if f:
		x = abs(ord(s[0]) - ord(s[3]))
		y = abs(int(s[1]) - int(s[4]))
		if x == 2 and y == 1 or (x == 1 and y == 2):
			pass
		else:
			f = False
		if f:
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


import re
valids = re.compile('[a-h][1-8]-[a-h][1-8]')
for _ in range(int(input())):
	expr = input()
	if valids.match(expr) and len(expr) == 5:
		(row_from, col_from) = (expr[0], int(expr[1]))
		(row_to, col_to) = (expr[3], int(expr[4]))
		a = abs(ord(row_to) - ord(row_from))
		b = abs(col_to - col_from)
		if a == 1 and b == 2 or (a == 2 and b == 1):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


def main():
	from sys import stdin, stdout
	inp = stdin.readline
	out = stdout.write
	col = ['1', '2', '3', '4', '5', '6', '7', '8']
	row = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
	move = [[2, 1], [2, -1], [1, 2], [1, -2], [-2, 1], [-2, -1], [-1, 2], [-1, -2]]
	t = int(inp())
	for _ in range(t):
		n = input()
		if len(n) != 5:
			print('Error')
			continue
		(a, b, c, d, e) = list(n)
		if a not in row or d not in row:
			print('Error')
			continue
		elif b not in col or e not in col:
			print('Error')
			continue
		elif c != '-':
			print('Error')
			continue
		start = [row[a], int(b)]
		end = [row[d], int(e)]
		for i in move:
			new_ = [start[0] + i[0], start[1] + i[1]]
			if new_ == end:
				print('Yes')
				break
		else:
			print('No')
main()


from sys import maxsize, stdout, stdin
mod = int(1000000000.0 + 7)
from collections import Counter, deque, defaultdict, OrderedDict
from math import factorial, gcd, log2, ceil, floor, inf, sqrt
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import combinations, permutations

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

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

def strp():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
mov2 = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
mov1 = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8}
for _ in range(int(input())):
	s = list(input())
	f = 1
	if len(s) == 5:
		if s[0] in mov2 and s[1] in mov1 and (s[2] == '-') and (s[3] in mov2) and (s[4] in mov1):
			r1 = mov2[s[0]]
			r2 = mov2[s[3]]
			c1 = mov1[s[1]]
			c2 = mov1[s[4]]
			a = abs(r1 - r2)
			b = abs(c1 - c2)
			if a == 1 and b == 2 or (a == 2 and b == 1):
				final = 1
			else:
				final = 0
		else:
			f = 0
	else:
		f = 0
	if f == 0:
		print('Error')
	elif final == 0:
		print('No')
	else:
		print('Yes')


col = ['1', '2', '3', '4', '5', '6', '7', '8']
row = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
move = [[2, 1], [2, -1], [1, 2], [1, -2], [-2, 1], [-2, -1], [-1, 2], [-1, -2]]
t = int(input())
for _ in range(t):
	n = input()
	if len(n) != 5:
		print('Error')
		continue
	(a, b, c, d, e) = list(n)
	if a not in row or d not in row:
		print('Error')
		continue
	elif b not in col or e not in col:
		print('Error')
		continue
	elif c != '-':
		print('Error')
		continue
	start = [row[a], int(b)]
	end = [row[d], int(e)]
	for i in move:
		new_ = [start[0] + i[0], start[1] + i[1]]
		if new_ == end:
			print('Yes')
			break
	else:
		print('No')


l1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
l2 = ['1', '2', '3', '4', '5', '6', '7', '8']
for t in range(int(input())):
	mov = input()
	if len(mov) != 5 or mov[0] not in l1 or mov[1] not in l2 or (mov[2] != '-') or (mov[3] not in l1) or (mov[4] not in l2):
		print('Error')
	else:
		x = abs(l1.index(mov[0]) - l1.index(mov[3]))
		y = abs(l2.index(mov[1]) - l2.index(mov[4]))
		if x > 2 or y > 2 or x + y != 3:
			print('No')
		else:
			print('Yes')


for _ in range(int(input())):
	s = input()
	l = s.split('-')
	if len(l) != 2:
		print('Error')
		continue
	s1 = l[0]
	s2 = l[1]
	eB = len(s1) == 2
	fB = len(s2) == 2
	aB = False
	bB = False
	cB = False
	dB = False
	if eB == True:
		x1 = ord(s1[0]) - ord('a')
		y1 = ord(s1[1]) - ord('0')
		aB = s1[0].isalpha() and 0 <= x1 <= 7
		bB = s1[1].isdigit() and 1 <= y1 <= 8
	if fB == True:
		x2 = ord(s2[0]) - ord('a')
		y2 = ord(s2[1]) - ord('0')
		cB = s2[0].isalpha() and 0 <= x2 <= 7
		dB = s2[1].isdigit() and 1 <= y2 <= 8
	if (aB and bB and cB and dB and eB and fB) == False:
		print('Error')
		continue
	if abs(x2 - x1) == 1 and abs(y2 - y1) == 2 or (abs(x2 - x1) == 2 and abs(y2 - y1) == 1):
		print('Yes')
	else:
		print('No')


__author__ = 'Ronald Kaiser'
__email__ = 'raios dot catodicos at gmail dot com'
in_range = lambda x: x >= 1 and x <= 8
list_in_range = lambda l: len(list(filter(in_range, l))) == len(l)
for _ in range(int(input())):
	s = input()
	if len(s) != 5:
		print('Error')
		continue
	(sc, sr, dc, dr) = (ord(s[0]) - 96, ord(s[1]) - 48, ord(s[3]) - 96, ord(s[4]) - 48)
	if not (s[2] == '-' and list_in_range([sc, sr, dc, dr])):
		print('Error')
		continue
	print('Yes' if abs((sc - dc) * (sr - dr)) == 2 else 'No')


t = int(input())
while t > 0:
	str = input()
	if len(str) != 5 or str[2] != '-':
		print('Error')
	elif (str[0] >= 'a' and str[0] <= 'h') and (str[3] >= 'a' and str[3] <= 'h') and (str[1] >= '1' and str[1] <= '8') and (str[4] >= '1' and str[4] <= '8'):
		if abs(ord(str[0]) - ord(str[3])) * abs(ord(str[4]) - ord(str[1])) == 2:
			print('Yes')
		else:
			print('No')
	else:
		print('Error')
	t -= 1


T = int(input())
for t in range(T):
	s = input()
	if len(s) == 5 and 'a' <= s[0] and (s[0] <= 'h') and ('1' <= s[1]) and (s[1] <= '8') and (s[2] == '-') and ('a' <= s[3]) and (s[3] <= 'h') and ('1' <= s[4]) and (s[4] <= '8'):
		if abs((ord(s[0]) - ord(s[3])) * (ord(s[1]) - ord(s[4]))) == 2:
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


def check_pair(s):
	if len(s) == 5 and s[0] >= 'a' and (s[0] <= 'h') and (s[1] >= '1') and (s[1] <= '8') and (s[2] == '-') and (s[3] >= 'a') and (s[3] <= 'h') and (s[4] >= '1') and (s[4] <= '8'):
		return True
	else:
		return False

def check_move(s):
	if abs(ord(s[0]) - ord(s[3])) == 1 and abs(int(s[1]) - int(s[4])) == 2 or (abs(ord(s[0]) - ord(s[3])) == 2 and abs(int(s[1]) - int(s[4])) == 1):
		return True
	else:
		return False
T = int(input())
ans = []
for _ in range(T):
	S = input()
	if not check_pair(S):
		ans.append('Error')
	elif check_move(S):
		ans.append('Yes')
	else:
		ans.append('No')
for i in ans:
	print(i)


dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
for _ in range(int(input())):
	string = input()
	if len(string) != 5:
		print('Error')
	elif string[2] != '-' or string[0] not in 'abcdefgh' or string[3] not in 'abcdefgh' or (string[1] not in '12345678') or (string[4] not in '12345678'):
		print('Error')
	else:
		array = [dic[string[0]], int(string[1]), dic[string[3]], int(string[4])]
		aa = [abs(array[0] - array[2]), abs(array[1] - array[3])]
		aa.sort()
		if aa == [1, 2]:
			print('Yes')
		else:
			print('No')


def checkAlpha(ch):
	return ord(ch) >= ord('a') and ord(ch) <= ord('h')

def checkNumber(ch):
	return ord(ch) >= ord('1') and ord(ch) <= ord('8')
for _ in range(int(input())):
	S = input()
	if len(S) == 5 and checkAlpha(S[0]) and checkNumber(S[1]) and checkAlpha(S[3]) and checkNumber(S[4]) and (S[2] == '-'):
		if abs(ord(S[0]) - ord(S[3])) == 2 and abs(ord(S[1]) - ord(S[4])) == 1:
			print('Yes')
		elif abs(ord(S[0]) - ord(S[3])) == 1 and abs(ord(S[1]) - ord(S[4])) == 2:
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


t = int(input())
ld = [1, 2, -1, -2]
for ic in range(t):
	s = input()
	if len(s) != 5:
		print('Error')
		continue
	if s[2] != '-':
		print('Error')
	else:
		a = s[0]
		b = s[1]
		c = s[3]
		d = s[4]
		if a not in 'abcdefgh' or c not in 'abcdefgh' or b not in '12345678' or (d not in '12345678'):
			print('Error')
		else:
			a = ord(a)
			c = ord(c)
			b = int(b)
			d = int(d)
			ac = a - c
			bd = b - d
			abcd = ac + bd
			if ac in ld and bd in ld and (abcd in [1, 3, -1, -3]):
				print('Yes')
			else:
				print('No')


d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
check = range(1, 9)
t = int(input())
for _ in range(t):
	try:
		move = input()
		if len(move) != 5 or move[2] != '-' or int(move[1]) not in check or (int(move[4]) not in check):
			print('Error')
			continue
		else:
			(start_1, start_2, end_1, end_2) = (move[0], int(move[1]), move[3], int(move[4]))
			if abs(d[start_1] - d[end_1]) == 1:
				if abs(start_2 - end_2) == 2:
					print('Yes')
				else:
					print('No')
			elif abs(d[start_1] - d[end_1]) == 2:
				if abs(start_2 - end_2) == 1:
					print('Yes')
				else:
					print('No')
			else:
				print('No')
	except:
		print('Error')


def getCoords(text):
	if len(text) != 5:
		return (None, None, None, None)
	if text[2] != '-' or not text[1].isdigit() or (not text[4].isdigit()):
		return (None, None, None, None)
	r1 = ord(text[0]) - ord('a')
	c1 = int(text[1]) - 1
	r2 = ord(text[3]) - ord('a')
	c2 = int(text[4]) - 1
	r1 = r1 if r1 >= 0 and r1 < 8 else None
	r2 = r2 if r2 >= 0 and r2 < 8 else None
	c1 = c1 if c1 >= 0 and c1 < 8 else None
	c2 = c2 if c2 >= 0 and c2 < 8 else None
	return (r1, c1, r2, c2)

def isValidKnightMove(r1, c1, r2, c2):
	d1 = abs(r1 - r2)
	d2 = abs(c1 - c2)
	return d1 == 2 and d2 == 1 or (d1 == 1 and d2 == 2)
TC = int(input())
for _ in range(TC):
	text = input()
	(r1, c1, r2, c2) = getCoords(text)
	if r1 == None or c1 == None or r2 == None or (c2 == None):
		print('Error')
	elif isValidKnightMove(r1, c1, r2, c2):
		print('Yes')
	else:
		print('No')


for t in range(int(input())):
	s = input()
	if len(s) != 5:
		print('Error')
		continue
	if s[2] != '-'[0]:
		print('Error')
		continue
	elif s[0] in 'abcdefgh' and s[1] in '12345678' and (s[3] in 'abcdefgh') and (s[4] in '12345678'):
		s1 = ord(s[0])
		s2 = int(s[1])
		s3 = ord(s[3])
		s4 = int(s[4])
		if abs(s1 - s3) == 2 and abs(s2 - s4) == 1 or (abs(s1 - s3) == 1 and abs(s2 - s4) == 2):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


def findit(s):
	if len(s) == 5 and s[0] <= 'h' and (s[0] >= 'a') and (s[3] <= 'h') and (s[3] >= 'a') and (s[1] < '9') and (s[1] > '0') and (s[4] < '9') and (s[4] > '0') and (s[2] == '-'):
		x1 = ord(s[0]) - ord('a')
		y1 = int(s[1]) - 1
		x2 = ord(s[3]) - ord('a')
		y2 = int(s[4]) - 1
		if x1 - 2 >= 0 and y1 - 1 >= 0 and (x2 == x1 - 2) and (y2 == y1 - 1):
			print('Yes')
			return
		if x1 - 1 >= 0 and y1 - 2 >= 0 and (x2 == x1 - 1) and (y2 == y1 - 2):
			print('Yes')
			return
		if x1 - 2 >= 0 and y1 + 1 < 8 and (x2 == x1 - 2) and (y2 == y1 + 1):
			print('Yes')
			return
		if x1 - 1 >= 0 and y1 + 2 < 8 and (x2 == x1 - 1) and (y2 == y1 + 2):
			print('Yes')
			return
		if x1 + 1 < 8 and y1 + 2 < 8 and (x2 == x1 + 1) and (y2 == y1 + 2):
			print('Yes')
			return
		if x1 + 2 < 8 and y1 + 1 < 8 and (x2 == x1 + 2) and (y2 == y1 + 1):
			print('Yes')
			return
		if x1 + 2 < 8 and y1 - 1 >= 0 and (x2 == x1 + 2) and (y2 == y1 - 1):
			print('Yes')
			return
		if x1 + 1 < 8 and y1 - 2 >= 0 and (x2 == x1 + 1) and (y2 == y1 - 2):
			print('Yes')
			return
		print('No')
		return
	else:
		print('Error')
t = int(input())
for i in range(t):
	s = input()
	findit(s)


def main():
	from re import fullmatch
	testCases = int(input())
	while testCases:
		string = input()
		match = fullmatch('[a-h][1-8]-[a-h][1-8]', string)
		if match != None:
			a1 = ord(string[0]) - 96
			b1 = ord(string[1]) - 96
			a2 = ord(string[3]) - 96
			b2 = ord(string[4]) - 96
			if abs((a1 - a2) * (b1 - b2)) == 2:
				print('Yes')
			else:
				print('No')
		else:
			print('Error')
		testCases -= 1
main()


for t in range(int(input())):
	s = str(input())
	if len(s) != 5 or s[2] != '-':
		print('Error')
	else:
		a = ord(s[0])
		b = ord(s[1])
		c = ord(s[3])
		d = ord(s[4])
		if a >= 97 and a <= 104 and (c >= 97) and (c <= 104) and (b >= 49) and (b <= 56) and (d >= 49) and (d <= 56):
			ans = []
			ans.append(abs(a - c))
			ans.append(abs(b - d))
			ans.sort()
			if ans[0] == 1 and ans[1] == 2:
				print('Yes')
			else:
				print('No')
		else:
			print('Error')


d = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
for _ in range(int(input())):
	a = input()
	try:
		if len(a) == 5 and a[0] in d and (a[1] in '12345678') and (a[2] == '-') and (a[3] in d) and (a[4] in '12345678'):
			try:
				x = [-2, -2, 2, 2, -1, 1, -1, 1]
				y = [1, -1, 1, -1, 2, 2, -2, -2]
				i = int(a[1])
				j = d[a[0]]
				destx = int(a[4])
				desty = d[a[3]]
				for ind in range(len(x)):
					newx = i + x[ind]
					newy = j + y[ind]
					if destx == newx and desty == newy:
						print('Yes')
						break
				else:
					print('No')
			except:
				print('No')
		else:
			print('Error')
	except:
		print('Error')


def main():
	from sys import stdin, stdout
	inp = stdin.readline
	out = stdout.write
	res = []
	t = int(inp().strip())
	for i in range(t):
		s = input()
		if len(s) != 5 or s[2] != '-':
			res.append('Error\n')
		elif not 49 <= ord(s[1]) <= 56 or not 49 <= ord(s[4]) <= 56:
			res.append('Error\n')
		elif not 97 <= ord(s[0]) <= 104 or not 97 <= ord(s[3]) <= 104:
			res.append('Error\n')
		elif (ord(s[0]) + 1 == ord(s[3]) or ord(s[0]) - 1 == ord(s[3])) and ord(s[1]) + 2 == ord(s[4]):
			res.append('Yes\n')
		elif (ord(s[1]) + 1 == ord(s[4]) or ord(s[1]) - 1 == ord(s[4])) and ord(s[0]) + 2 == ord(s[3]):
			res.append('Yes\n')
		elif (ord(s[1]) + 1 == ord(s[4]) or ord(s[1]) - 1 == ord(s[4])) and ord(s[0]) - 2 == ord(s[3]):
			res.append('Yes\n')
		elif (ord(s[0]) + 1 == ord(s[3]) or ord(s[0]) - 1 == ord(s[3])) and ord(s[1]) - 2 == ord(s[4]):
			res.append('Yes\n')
		else:
			res.append('No\n')
	for i in range(t):
		out(res[i])
main()


T = int(input())
for i in range(T):
	s = input()
	if len(s) != 5:
		print('Error')
	elif (s[0] < 'a' or s[0] > 'h') or (s[1] < '1' or s[1] > '8') or s[2] != '-' or (s[3] < 'a' or s[3] > 'h') or (s[4] < '1' or s[4] > '8'):
		print('Error')
	else:
		c1 = ord(s[0])
		c2 = ord(s[3])
		d1 = int(s[1])
		d2 = int(s[4])
		if abs((c1 - c2) * (d1 - d2)) == 2:
			print('Yes')
		else:
			print('No')


map1 = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8}
map2 = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8}
t = int(input())
for _ in range(t):
	list1 = list(input())
	inp = 1
	if len(list1) == 5:
		if list1[0] in map2 and list1[1] in map1 and (list1[2] == '-') and (list1[3] in map2) and (list1[4] in map1):
			row1 = map2[list1[0]]
			row2 = map2[list1[3]]
			col1 = map1[list1[1]]
			col2 = map1[list1[4]]
			row_diff = abs(row1 - row2)
			col_diff = abs(col1 - col2)
			if row_diff == 1 and col_diff == 2 or (row_diff == 2 and col_diff == 1):
				move = 1
			else:
				move = 0
		else:
			inp = 0
	else:
		inp = 0
	if inp == 0:
		print('Error')
	elif move == 0:
		print('No')
	else:
		print('Yes')


def solve():
	s = input()
	if len(s) != 5:
		print('Error')
	elif (s[0] < 'a' or s[0] > 'h') or (s[1] < '1' or s[1] > '8') or s[2] != '-' or (s[3] < 'a' or s[3] > 'h') or (s[4] < '1' or s[4] > '8'):
		print('Error')
	else:
		c1 = ord(s[0])
		c2 = ord(s[3])
		d1 = int(s[1])
		d2 = int(s[4])
		if abs((c1 - c2) * (d1 - d2)) == 2:
			print('Yes')
		else:
			print('No')
t = int(input())
while t != 0:
	solve()
	t -= 1


def isValid(str):
	if len(str) == 5 and str[2] == '-':
		if (str[0] >= 'a' and str[0] <= 'h') and (str[3] >= 'a' and str[3] <= 'h'):
			if (str[1] >= '1' and str[1] <= '8') and (str[4] >= '1' and str[4] <= '8'):
				return True
			else:
				return False
		else:
			return False
	else:
		return False

def isKnightMove(str):
	if abs(ord(str[0]) - ord(str[3])) == 1 and abs(ord(str[1]) - ord(str[4])) == 2:
		return True
	elif abs(ord(str[0]) - ord(str[3])) == 2 and abs(ord(str[1]) - ord(str[4])) == 1:
		return True
	else:
		return False
T = int(input())
for i in range(T):
	move = input()
	if isValid(move):
		if isKnightMove(move):
			print('Yes')
		else:
			print('No')
	else:
		print('Error')


for _ in range(int(input())):
	s1 = input()
	tmp = 'abcdefgh'
	tmp2 = '12345678'
	flag = 1
	if len(s1) != 5 or s1[0] not in tmp or s1[4] not in tmp2 or (s1[2] != '-') or (s1[1] not in tmp2) or (s1[3] not in tmp):
		flag = -1
	else:
		sol = []
		if chr(ord(s1[0]) - 2) in tmp and chr(ord(s1[1]) + 1) in tmp2:
			sol.append(chr(ord(s1[0]) - 2) + chr(ord(s1[1]) + 1))
		if chr(ord(s1[0]) - 2) in tmp and chr(ord(s1[1]) - 1) in tmp2:
			sol.append(chr(ord(s1[0]) - 2) + chr(ord(s1[1]) - 1))
		if chr(ord(s1[0]) - 1) in tmp and chr(ord(s1[1]) + 2) in tmp2:
			sol.append(chr(ord(s1[0]) - 1) + chr(ord(s1[1]) + 2))
		if chr(ord(s1[0]) - 1) in tmp and chr(ord(s1[1]) - 2) in tmp2:
			sol.append(chr(ord(s1[0]) - 1) + chr(ord(s1[1]) - 2))
		if chr(ord(s1[0]) + 1) in tmp and chr(ord(s1[1]) + 2) in tmp2:
			sol.append(chr(ord(s1[0]) + 1) + chr(ord(s1[1]) + 2))
		if chr(ord(s1[0]) + 1) in tmp and chr(ord(s1[1]) - 2) in tmp2:
			sol.append(chr(ord(s1[0]) + 1) + chr(ord(s1[1]) - 2))
		if chr(ord(s1[0]) + 2) in tmp and chr(ord(s1[1]) + 1) in tmp2:
			sol.append(chr(ord(s1[0]) + 2) + chr(ord(s1[1]) + 1))
		if chr(ord(s1[0]) + 2) in tmp and chr(ord(s1[1]) - 1) in tmp2:
			sol.append(chr(ord(s1[0]) + 2) + chr(ord(s1[1]) - 1))
		if s1[3:5] not in sol:
			flag = 0
	if flag == -1:
		print('Error')
	elif flag == 0:
		print('No')
	else:
		print('Yes')


t = int(input())

def knight(s):
	flag = 1
	if len(s) == 5:
		if ord(s[0]) in range(ord('a'), ord('h') + 1) and ord(s[3]) in range(ord('a'), ord('h') + 1):
			if s[2] == '-':
				if ord(s[1]) in range(ord('1'), ord('8') + 1) and ord(s[4]) in range(ord('1'), ord('8') + 1):
					flag = 0
	if flag == 1:
		return 'Error'
	elif abs(ord(s[0]) - ord(s[3])) == 1 and abs(ord(s[1]) - ord(s[4])) == 2:
		return 'Yes'
	elif abs(ord(s[0]) - ord(s[3])) == 2 and abs(ord(s[1]) - ord(s[4])) == 1:
		return 'Yes'
	else:
		return 'No'
for i in range(t):
	xx = input()
	print(knight(xx))