a,b=input().split()

lis=(("1","3","5","7","8","10","12"),("4","6","9","11"),("2"))

for gn, row in enumerate(lis):

    try:

        A=(gn, row.index(a))

        break

    except ValueError:

        pass

for gn, row in enumerate(lis):

    try:

        B=(gn, row.index(b))

        break

    except ValueError:

        pass    

print(("Yes" if A[0]==B[0] else "No"))    
x,y = list(map(int,input().split(" ")))

a=(1,3,5,7,8,10,12)

b=(4,6,9,11)

if (x in a and y in a) or (x in b and y in b):

    print("Yes")

else:

    print("No")
a, b = input().split()
lis = (("1", "3", "5", "7", "8", "10", "12"), ("4", "6", "9", "11"), ("2"))
for gn, row in enumerate(lis):
    try:
        A = (gn, row.index(a))
        break
    except ValueError:
        pass
for gn, row in enumerate(lis):
    try:
        B = (gn, row.index(b))
        break
    except ValueError:
        pass
print(("Yes" if A[0] == B[0] else "No"))

x, y = list(map(int, input().split(" ")))
a = (1, 3, 5, 7, 8, 10, 12)
b = (4, 6, 9, 11)
if (x in a and y in a) or (x in b and y in b):
    print("Yes")
else:
    print("No")

-a, b = input().split() -lis = (("1", "3", "5", "7", "8", "10", "12"), ("4", "6", "9", "11"), ("2")) -for gn, row in enumerate(lis): -    try: -        A = (gn, row.index(a)) -        break -    except ValueError: -        pass -for gn, row in enumerate(lis): -    try: -        B = (gn, row.index(b)) -        break -    except ValueError: -        pass -print(("Yes" if A[0] == B[0] else "No")) +x, y = list(map(int, input().split(" "))) +a = (1, 3, 5, 7, 8, 10, 12) +b = (4, 6, 9, 11) +if (x in a and y in a) or (x in b and y in b): +    print("Yes") +else: +    print("No")