import sys import copy input_list = list() for i in range(2): row_list = list() line = input().split(" ") for x in line: row_list.append(int(x)) input_list.append(row_list) x = 0 y = 0 for count in range(9): # work a = copy.copy(input_list[0]) b = copy.copy(input_list[1]) # exchange change_a = a[x] change_b = b[y] a[x] = change_b b[y] = change_a # judge if len(a) != len(set(a)) or len(b) != len(set(b)): print("No") sys.exit() if max(a) == a[1] or min(a) == a[1]: if max(b) == b[1] or min(b) == b[1]: print("Yes") sys.exit() # count up if y == 2: x += 1 y = 0 else: y += 1 print("No")