def freq_dict(A: list)-> dict:
d={}
for i in A:
d[i] = d.get(i,0)+1
return d;
t=int(input())
for i in range(t):
# x, y = map(int, input().split())
# A = list(map(int, input().split()))
s=input().strip();
#print(len(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' ):
# fetch the first move and second move on the chess board
first_move=[int(ord(s[0])),int(s[1])];
second_move=[int(ord(s[3])),int(s[4])];
if(abs(first_move[0]-second_move[0]) == 2 and abs(first_move[1]-second_move[1])==1):
print("Yes")
elif(abs(first_move[0]-second_move[0]) == 1 and abs(first_move[1]-second_move[1])==2):
print("Yes")
else:
print("No")
else:
print("Error")
def freq_dict(A: list) -> dict:
"""Creates a frequency dictionary from a given list."""
d = {}
for i in A:
d[i] = d.get(i, 0) + 1
return d
def is_valid_knight_move(s: str) -> bool:
"""Checks if the given move is a valid knight move in chess."""
if len(s) != 5 or s[2] != '-':
return False
# Extracting and validating chessboard coordinates
if not ('a' <= s[0] <= 'h' and '1' <= s[1] <= '8' and 'a' <= s[3] <= 'h' and '1' <= s[4] <= '8'):
return False
# Convert chess notation to numerical coordinates
first_move = [ord(s[0]) - ord('a') + 1, int(s[1])]
second_move = [ord(s[3]) - ord('a') + 1, int(s[4])]
# Check for valid knight move
return (abs(first_move[0] - second_move[0]) == 2 and abs(first_move[1] - second_move[1]) == 1) or \
(abs(first_move[0] - second_move[0]) == 1 and abs(first_move[1] - second_move[1]) == 2)
t = int(input("Enter number of test cases: "))
for _ in range(t):
s = input().strip()
if is_valid_knight_move(s):
print("Yes")
else:
print("No" if len(s) == 5 else "Error")