y, ***p(int, input().split())
y1, m1, d1 = map(int, input().split())
if y1 >= y:
print("yes")
elif y1 >= y and m1 >= m:
print("yes")
elif y1 >= y and m1 >= m and d1 >= d:
print("yes")
else:
print("no")
y, ***p(int, input().split())
y1, m1, d1 = map(int, input().split())
if y1 >= y:
print("yes")
elif y1 >= y and m1 >= m:
print("yes")
elif y1 >= y and m1 >= m and d1 >= d:
print("yes")
else:
print("no")