①. x축 방향으로 ±2만큼 이동하고 y축 방향으로 ±1만큼 이동
②. x축 방향으로 ±1만큼 이동하고 y축 방향으로 ±2만큼 이동
③. 한 번 방문했던 지점은 재방문이 불가하다.
visited = []
ans = "Valid"
for i in range(36):
if i == 0:
start = input()
start_location = start
visited.append(start)
elif i < 35:
now_location = input()
if (abs(ord(start_location[0]) - ord(now_location[0])) == 2 and abs(int(start_location[1]) - int(now_location[1])) == 1) and now_location not in visited:
pass
elif (abs(ord(start_location[0]) - ord(now_location[0])) == 1 and abs(int(start_location[1]) - int(now_location[1])) == 2) and now_location not in visited:
pass
else:
ans = "Invalid"
visited.append(now_location)
start_location = now_location
else:
now_location = input()
if (abs(ord(now_location[0]) - ord(start[0])) == 2 and abs(int(now_location[1]) - int(start[1])) == 1) and now_location not in visited:
pass
elif (abs(ord(now_location[0]) - ord(start[0])) == 1 and abs(int(now_location[1]) - int(start[1])) == 2) and now_location not in visited:
pass
else:
ans = "Invalid"
visited.append(now_location)
visited = list(set(visited)) # 중복되는 요소를 제거
if len(visited) == 35:
print(ans)
else:
print(ans)