You are given names of two days of the week.

Please, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Both months should belong to one year.

In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.

Names of the days of the week are given with lowercase English letters: "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".


-----Input-----

The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday".


-----Output-----

Print "YES" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "NO" (without quotes).


-----Examples-----
Input
monday
tuesday

Output
NO

Input
sunday
sunday

Output
YES

Input
saturday
tuesday

Output
YES



-----Note-----

In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.

In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday.

Difficulty: competition

Starter code:

Solutions:
a, b = input(), input()
d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
x, y = d[a], d[b]
flag = (y - x) % 7 in {0, 2, 3}
print('YES' if flag else 'NO')


__author__ = 'Think'
day1=input()
day2=input()
days={"monday":1, "tuesday":2, "wednesday":3, "thursday":4, "friday":5, "saturday":6, "sunday":7}
num1=days[day1]
num2=days[day2]
diff=(num2-num1)%7
if diff in [0, 2, 3]:
	print("YES")
else:
	print("NO")

#!/usr/bin/env python3


def main():
    days = ["sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
    try:
        while True:
            a = days.index(input())
            b = days.index(input())
            print("YES" if (b - a) % 7 in (0, 2, 3) else "NO")

    except EOFError:
        pass


main()


def main():
    a = input().strip()
    b = input().strip()
    q = [28, 30, 31]
    days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
    f = False
    for x in q:
        if (days.index(a) + x) % 7 == days.index(b):
            f = True
            break
    if f:
        print("YES")
    else:
        print("NO")
main()

m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
wd = ['monday', 'tuesday', 'wednesday', "thursday", "friday", "saturday", "sunday"]
a, b = [wd.index(input()) for i in range(2)]
for i in range(7):
    cur = i
    for j in range(11):
        nxt = (cur + m[j]) % 7
        if cur == a and nxt == b:
            print('YES')
            return
        cur = nxt
print('NO')

days = "monday tuesday wednesday thursday friday saturday sunday".split()

offs = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

d1 = days.index(input())
d2 = days.index(input())

for o in offs:
    if (d1 + o) % 7 == d2:
        print("YES")
        break
else:
    print("NO")

l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]

def gi(s):
	for i in range(len(days)):
		if days[i] == s:
			return i

def solve():
	start = input()
	end = input()
	for i in range(len(l) - 1):
		f = l[i]
		diff = f % 7
		starti = gi(start)
		if days[(starti + diff) % 7] == end:
			return True
	return False



res = solve()
print("YES" if res else "NO")

days = [28, 30, 31]
week = ['monday',
        'tuesday',
        'wednesday',
        'thursday',
        'friday',
        'saturday',
        'sunday']

a = input()
b = input()

for index, name in enumerate(week):
    if name == a:
        ind = index

flag = False
for mo in days:
    if week[(ind + mo) % 7] == b:
        flag = True
if flag:
    print('YES')
else:
    print('NO')


a = input()
b = input()
D = {'monday': 0, 'tuesday':1, 'wednesday':2, 'thursday':3, 'friday':4, 'saturday':5, 'sunday':6}
x, y = D[a], D[b]
if (y - x)%7 == 2 or (y - x)%7 == 3 or (y - x)%7 == 0:
    print('YES')
else:
    print('NO')


f = input()
s = input()
day = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"]
length = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(11):
    if day[(day.index(f) + length[i]) % 7] == s:
        print('YES')
        return
print('NO')

ms = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
d = dict(list(zip(["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"], list(range(7)))))

a, b = d[input()], d[input()]
good = False
for i in range(11):
    if (a + ms[i]) % 7 == b:
        good = True

print('YES' if good else 'NO')


s1 = input()
s2 = input()
n1 = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"].index(s1)
n2 = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"].index(s2)
if n1 == n2:
    print("YES")
else:
    if (n2 - n1 + 7) % 7 in [2, 3]:
        print("YES")
    else:
        print("NO")

months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
weekday1 = input()
weekday2 = input()

days = {
    'monday': 0,
    'tuesday': 1,
    'wednesday': 2,
    'thursday': 3,
    'friday': 4,
    'saturday': 5,
    'sunday': 6
}

def main():
    for mon in months[:-1]:
        if (mon + days[weekday1]) % 7 == days[weekday2]:
            print("YES")
            return
    print("NO")
    return
    
main()

cal = {i:j for i, j in zip('monday tuesday wednesday thursday friday saturday sunday'.split(), range(7))}
fst = cal[input()]
snd = cal[input()]
gre = {0, 2, 3}
print('YES' if (snd - fst) % 7 in gre else 'NO')

names = {"monday":0, "tuesday":1, "wednesday":2, "thursday":3, "friday":4, "saturday":5, "sunday":6,}

a = names[input().strip()]
b = names[input().strip()]

if (a == b) or ((a + 2) % 7 == b) or ((a + 3) % 7 == b):
	print("YES")
else:
	print("NO")



m = [3,0,2]

a = input()
b = input()

month = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]

if (month.index(b) - month.index(a)) % 7 in m:
    print('YES')
else:
    print('NO')


d = dict()
d['monday'] = 0
d['tuesday'] = 1
d['wednesday'] = 2
d['thursday'] = 3
d['friday'] = 4
d['saturday'] = 5
d['sunday'] = 6
s1 = input()
s2 = input()
x =  (d[s2] - d[s1] + 7) % 7
if x == 0 or x == 2 or x == 3:
    print('YES')
else:
    print('NO')


day = ("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday")
a = input()
b = input()
i = day.index(a)
if day[i] == b or day[(i + 2) % 7] == b or day[(i + 3) % 7] == b:
    print("YES")
else:
    print("NO")


#!/usr/bin/env python3
dia_uno= input()
dia_dos=input()
if(dia_uno==dia_dos):
  print("YES")
  quit()
dias=["monday", "tuesday", "wednesday","thursday", "friday", "saturday", "sunday","monday", "tuesday", "wednesday"]
indice= dias.index(dia_uno)
if (dias[indice+2]==dia_dos or dias[indice+3]==dia_dos):
    print("YES")
else:
    print("NO")


s1 = input()
s2 = input()

d = dict()

d['monday'] = 1
d['tuesday'] = 2
d['wednesday'] = 3
d['thursday'] = 4
d['friday'] = 5
d['saturday'] = 6
d['sunday'] = 0

if (d[s1] + 31 % 7) % 7 == d[s2] or (d[s1] + 30 % 7) % 7 == d[s2] or (d[s1] + 28 % 7) % 7 == d[s2]:
    print("YES")
else:
    print("NO")

d = {
    'monday': 0,
    'tuesday': 1,
    'wednesday': 2,
    'thursday': 3,
    'friday': 4,
    'saturday': 5,
    'sunday': 6
}

first = d[input()]

second = d[input()]


months = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

for i in range(11):
    m1, m2 = months[i], months[i+1]
    if (m1 + first) % 7 == second:
        print('YES')
        break
else:
    print('NO')

a = [28, 30, 31]
b = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
c = {}
for i in range(7):
    c[b[i]] = i
d1 = c[input()]
d2 = c[input()]
for i in a:
    if ((d1 + i) % 7) == d2:
        print("YES")
        return
print("NO")



# ol = [0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5]
# dl = [3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2]
wl = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']

a = wl.index(input())
b = wl.index(input())

if (b - a) % 7 in (0, 2, 3):
    print('YES')
else:
    print('NO')


d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}

first = d[input()]
second = d[input()]

cnt = (second + 7 - first) % 7

s = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30}

for v in s:
    if v % 7 == cnt:
        print('YES')
        break
else:
    print('NO')