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: EASY
Tags: Implementation

Starter code:

Solutions:
(First_day, Second_day) = (input(), input())
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
if days.index(Second_day) - days.index(First_day) in [0, 2, 3, -4, -5]:
	print('YES')
else:
	print('NO')


n = input()
m = input()
a = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
k = a.index(n)
for i in range(k, 7):
	s = a[i]
	a.remove(s)
	a.insert(i - k, s)
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in l:
	p = i % 7
	if m == a[p]:
		print('YES')
		break
else:
	print('NO')


a = input()
b = input()
c = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
d = c[b] - c[a]
if a == b:
	print('YES')
elif d == 2 or d == 3:
	print('YES')
elif d < 0:
	d = c[b] + 7 - c[a]
	if d == 2 or d == 3:
		print('YES')
	else:
		print('NO')
else:
	print('NO')


day1 = input()
day2 = input()
week = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
if week[day2] == (week[day1] + 2) % 7 or week[day2] == (week[day1] + 3) % 7 or week[day2] == week[day1] or (week[day2] == week[day1] + 2) or (week[day2] == week[day1] + 3):
	print('YES')
else:
	print('NO')


d = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
d1 = d[input()]
d2 = d[input()]
if (28 - d2 + d1) % 7 == 0 or (30 - d2 + d1) % 7 == 0 or (31 - d2 + d1) % 7 == 0:
	print('YES')
else:
	print('NO')


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()


one = input()
two = input()
t = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
if (t[two] - t[one]) % 7 in [3, 2, 0]:
	print('YES')
else:
	print('NO')


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')


from sys import stdin
from sys import stdout
days = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
day1 = days[stdin.readline()[:-1]]
day2 = days[stdin.readline()[:-1]]
if day1 == day2 or (day1 + 2) % 7 == day2 or (day1 + 3) % 7 == day2:
	stdout.write('YES')
else:
	stdout.write('NO')


days = ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')
a = days.index(input())
b = days.index(input())
if b in (a, (a + 2) % len(days), (a + 3) % len(days)):
	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')


from collections import defaultdict
import sys, os, math
week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
s1 = input()
s2 = input()
if (week.index(s2) - week.index(s1) + 7) % 7 in [0, 2, 3]:
	print('YES')
else:
	print('NO')


a = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d1 = a.index(input())
d2 = a.index(input())
cnt = 0
while d1 != d2:
	d1 += 1
	d1 %= 7
	cnt += 1
print('YES' if cnt == 0 or cnt == 2 or cnt == 3 else 'NO')


s = input()
S = input()
l = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
value = (d[S] - d[s]) % 7
if value == 0:
	print('YES')
elif value == 2 or value == 3:
	print('YES')
else:
	print('NO')


l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
day1 = input()
day2 = input()
d = l.index(day2) - l.index(day1)
if d < 0:
	d = d + 7
if d == 0 or d == 2 or d == 3:
	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')


week = ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')
(a, b) = (input(), input())
print(('NO', 'YES')[any(((week.index(a) + i) % 7 == week.index(b) for i in (0, 2, 3)))])


months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(m1, m2) = (input(), input())
(m, n) = (days.index(m1), days.index(m2))
condition = False
for x in range(7):
	a = x
	for y in months:
		temp = a
		a += y
		a %= 7
		if temp == m and a == n:
			print('YES')
			condition = True
			break
	if condition:
		break
else:
	print('NO')


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
f = cin()[:-1]
s = cin()[:-1]
d = {'saturday': 1, 'sunday': 2, 'monday': 3, 'tuesday': 4, 'wednesday': 5, 'thursday': 6, 'friday': 7}
l = [0, 2, 3]
y = (d[f] > d[s]) * (d[s] - d[f]) % 7 + (d[f] < d[s]) * (d[s] - d[f])
if y in l:
	cout('YES')
else:
	cout('NO')


s1 = input()
s2 = input()
l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(x1, x2) = (l.index(s1), l.index(s2))
xx = x2 - x1
if xx < 0:
	xx += 7
if xx == 0 or xx == 2 or xx == 3:
	print('YES')
else:
	print('NO')


ms = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
d = dict(zip(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], 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')


day1 = input()
day2 = input()
dm = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
df = dm[day2] - dm[day1]
if any(((d - df) % 7 == 0 for d in [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31])):
	print('YES')
else:
	print('NO')


first = input()
second = input()
all_week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
all_month = [28, 30, 31]
all_month_mod = [0, 2, 3]
for i in range(len(all_week)):
	if all_week[i] == first:
		first = i
	if all_week[i] == second:
		second = i
var = 0
if second < first:
	var = second + 7 - first
else:
	var = second - first
found = False
for mod in all_month_mod:
	if mod == var:
		print('YES')
		found = True
if not found:
	print('NO')


d = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
d1 = input()
d2 = input()
i = d.index(d1)
c = 0
while True:
	if d[i] == d2:
		break
	i = (i + 1) % 7
	c += 1
if c == 0 or c == 2 or c == 3:
	print('YES')
else:
	print('NO')


s = input()
t = input()
d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(0, 11):
	if a[i] % 7 == (7 - d[s] + d[t]) % 7:
		print('YES')
		exit()
print('NO')


a = input()
b = input()
if a == 'monday':
	if b == 'monday' or b == 'wednesday' or b == 'thursday':
		print('YES')
	else:
		print('NO')
if a == 'tuesday':
	if b == 'tuesday' or b == 'friday' or b == 'thursday':
		print('YES')
	else:
		print('NO')
if a == 'wednesday':
	if b == 'friday' or b == 'wednesday' or b == 'saturday':
		print('YES')
	else:
		print('NO')
if a == 'thursday':
	if b == 'saturday' or b == 'sunday' or b == 'thursday':
		print('YES')
	else:
		print('NO')
if a == 'friday':
	if b == 'friday' or b == 'sunday' or b == 'monday':
		print('YES')
	else:
		print('NO')
if a == 'saturday':
	if b == 'saturday' or b == 'tuesday' or b == 'monday':
		print('YES')
	else:
		print('NO')
if a == 'sunday':
	if b == 'sunday' or b == 'tuesday' or b == 'wednesday':
		print('YES')
	else:
		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')


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')
elif (n2 - n1 + 7) % 7 in [2, 3]:
	print('YES')
else:
	print('NO')


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
ans = [0, 2, 3]
s = input()
t = input()
if any((days[(days.index(s) + ans[i]) % 7] == t for i in range(3))):
	print('YES')
else:
	print('NO')


day_to_number = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
number_to_day = {1: 'monday', 2: 'tuesday', 3: 'wednesday', 4: 'thursday', 5: 'friday', 6: 'saturday', 7: 'sunday'}
one_day = input()
another_day = input()
first_variant = ''
second_variant = ''
third_variant = ''
one_day = day_to_number[one_day]
result = one_day + 3
if result > 7:
	result -= 7
another_result = one_day + 2
if another_result > 7:
	another_result -= 7
third_result = one_day
first_variant = number_to_day[result]
second_variant = number_to_day[another_result]
third_variant = number_to_day[third_result]
if first_variant == another_day or second_variant == another_day or third_variant == another_day:
	print('Yes')
else:
	print('NO')


x = str(input())
y = str(input())
day = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
year = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for h in range(12):
	v = day.index(x)
	for i in range(year[h]):
		if v < 6:
			v += 1
		else:
			v = 0
	if y == day[v]:
		print('YES')
		break
	elif h == 11:
		print('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')


W = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(a, b) = (W.index(input()), W.index(input()))
print('YES' if [True, False, True, True, False, False, False][(b - a) % 7] else 'NO')


MONTH_LENGTHS = [28, 30, 31]
DAYS = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
start_day_current = input()
start_day_next = input()
start_day_current_index = DAYS[start_day_current]
start_day_next_index = DAYS[start_day_next]
for length in MONTH_LENGTHS:
	if (start_day_current_index + length) % 7 == start_day_next_index:
		print('YES')
		break
else:
	print('NO')


s = input()
t = input()
x = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
ss = x.index(s)
tt = x.index(t)
if s == t:
	print('YES')
	exit()
if tt - ss == 2 or tt - ss == 3:
	print('YES')
elif tt - ss + 7 == 2 or tt - ss + 7 == 3:
	print('YES')
else:
	print('NO')


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(frstDay, scndDay) = (input(), input())
if days[days.index(scndDay)] == days[days.index(frstDay)] or days[days.index(scndDay) - 2] == days[days.index(frstDay)] or days[days.index(scndDay) - 3] == days[days.index(frstDay)]:
	print('YES')
else:
	print('NO')


a = str(input())
b = str(input())
c = [0, 2, 3, -4, -5]
cnt = 0
x = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
for i in range(7):
	if a == x[i]:
		aa = i + 1
for j in range(7):
	if b == x[j]:
		bb = j + 1
for k in range(5):
	if c[k] == bb - aa:
		cnt = 1
		break
if cnt == 1:
	print('YES\n')
else:
	print('NO\n')
cnt = 0


t = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
f = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
a = input()
b = input()
x = 0
for k in range(len(f) - 1):
	h = f[k] % 7
	g = (t.index(a) + h) % 7
	if t[g] == b:
		print('YES')
		x += 1
		break
if x == 0:
	print('NO')


day_name = dict()
day_name['monday'] = 1
day_name['tuesday'] = 2
day_name['wednesday'] = 3
day_name['thursday'] = 4
day_name['friday'] = 5
day_name['saturday'] = 6
day_name['sunday'] = 7
day1 = input()
day2 = input()
days_in_months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
day_gap = (day_name[day2] - day_name[day1]) % 7
for i in days_in_months:
	if i % 7 == day_gap:
		print('YES')
		exit()
print('NO')


d = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
f = str(input())
s = str(input())
x = d.index(f)
a = 28 % 7
b = 30 % 7
c = 31 % 7
if d[x + a] == s or d[x + b] == s or d[x + c] == s:
	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()


lookup = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
d1 = lookup[input()]
d2 = lookup[input()]
diffs = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(len(diffs)):
	if (d1 + diffs[i]) % 7 == d2:
		print('YES')
		exit(0)
print('NO')
exit(0)


days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
dow = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
first = dow.index(input())
second = dow.index(input())
diff = second - first
for start in range(0, 7):
	curr_day = start
	for (idx, month) in enumerate(days):
		if curr_day == first:
			if idx != len(days) - 1:
				if (month % 7 + curr_day) % 7 == second:
					print('YES')
					import sys
					sys.exit(0)
		curr_day = (month % 7 + curr_day) % 7
print('NO')


(day1, day2) = (input(), input())
a = {'sunday': 0, 'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6}
if a[day2] < a[day1]:
	a[day2] += 7
diff = abs(a[day2] - a[day1])
if diff == 0 or diff == 3 or diff == 2:
	print('YES')
else:
	print('NO')


day = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
(a, b) = (day[input()], day[input()])
if b >= a:
	c = b - a
else:
	c = 7 + b - a
if str(c) in '023':
	print('YES')
else:
	print('NO')


a = ['su', 'mo', 'tu', 'we', 'th', 'fr', 'sa']
b = a.index(input()[:2])
c = a.index(input()[:2])
if (c - b) % 7 in [0, 2, 3]:
	print('YES')
else:
	print('NO')


m = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d2 = m.index(input())
d1 = m.index(input())
if d1 >= d2:
	if d1 - d2 == 0 or d1 - d2 == 3 or d1 - d2 == 2:
		print('YES')
	else:
		print('NO')
elif d2 - d1 == 4 or d2 - d1 == 5:
	print('YES')
else:
	print('NO')


f = input()
s = input()

def strToDay(s):
	if s == 'monday':
		return 1
	elif s == 'tuesday':
		return 2
	elif s == 'wednesday':
		return 3
	elif s == 'thursday':
		return 4
	elif s == 'friday':
		return 5
	elif s == 'saturday':
		return 6
	else:
		return 7

def dayPlusN(t, n):
	for i in range(n):
		t += 1
		if t == 8:
			t = 1
	return t
ff = strToDay(f)
ss = strToDay(s)
if ff == ss:
	print('YES')
elif ff < ss and (ff + 2 == ss or ff + 3 == ss):
	print('YES')
elif ff > ss and (dayPlusN(ff, 2) == ss or dayPlusN(ff, 3) == ss):
	print('YES')
else:
	print('NO')


arr = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'] * 2
a = input()
b = input()
if a == b:
	print('YES')
else:
	(pos1, pos2) = (None, None)
	for i in range(14):
		if arr[i] == a:
			pos1 = i
			break
	for i in range(i + 1, 14):
		if arr[i] == b:
			pos2 = i
			break
	if pos2 - pos1 in (2, 3):
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
dom = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
wd = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
day1 = input()
day2 = input()
day1 = wd.index(day1)
day2 = wd.index(day2)
for d in dom[:-2]:
	if (day1 + d) % 7 == day2:
		print('YES')
		exit()
print('NO')


import math

def main_function():
	day_1 = input()
	day_2 = input()
	months = [28 % 7, 30 % 7, 31 % 7]
	weeks = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
	int_day_1 = weeks.index(day_1)
	int_day_2 = weeks.index(day_2)
	is_answer_found = False
	if int_day_2 >= int_day_1:
		dif = int_day_2 - int_day_1
	else:
		dif = 7 - int_day_1 + int_day_2
	if dif in months:
		print('YES')
	else:
		print('NO')
main_function()


l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = l.index(input())
b = (l.index(input()) - a + 7) % 7
if b == 0 or b == 2 or b == 3:
	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')


day_num = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
d1 = input()
d2 = input()
day_diff = 0
if day_num[d1] > day_num[d2]:
	day_diff = 7 - day_num[d1] + day_num[d2]
else:
	day_diff = day_num[d2] - day_num[d1]
res = 'NO'
if day_diff == 3:
	res = 'YES'
if day_diff == 2:
	res = 'YES'
if day_diff == 0:
	res = 'YES'
print(res)


day = [0, 0]
(day[0], day[1]) = (input(), input())
for i in range(2):
	if day[i] == 'monday':
		day[i] = 1
	elif day[i] == 'tuesday':
		day[i] = 2
	elif day[i] == 'wednesday':
		day[i] = 3
	elif day[i] == 'thursday':
		day[i] = 4
	elif day[i] == 'friday':
		day[i] = 5
	elif day[i] == 'saturday':
		day[i] = 6
	else:
		day[i] = 7
if day[0] == day[1] or (day[0] + 1) % 7 + 1 == day[1] or (day[0] + 2) % 7 + 1 == day[1]:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = days.index(input().strip())
b = days.index(input().strip())
f = 0
if b == a % 7:
	f = 1
if b == (a + 2) % 7:
	f = 1
if b == (a + 3) % 7:
	f = 1
if f:
	print('YES')
else:
	print('NO')


map = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
a = input()
b = input()
a_int = map.get(a)
b_int = map.get(b)
if a_int == b_int:
	print('YES')
elif b_int - a_int == 3 or b_int + 7 - a_int == 3:
	print('YES')
elif b_int - a_int == 2 or b_int + 7 - a_int == 2:
	print('YES')
else:
	print('NO')


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()


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
dic = {d: i + 1 for (i, d) in enumerate(days)}
A = input()
B = input()
a = dic[A]
b = dic[B]
x = b - a
if x < 0:
	x += 7
if x == 3 or x == 0 or x == 2:
	print('YES')
else:
	print('NO')


def solveA(first_day, second_day):
	months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	months_first_days = [None] * len(months)
	for start_day in range(1, 8):
		day_today = start_day
		for month in months:
			months_first_days.append(day_today)
			for day in range(month):
				day_today += 1
				if day_today > 7:
					day_today = 1
		n = len(months_first_days)
		for i in range(1, n):
			if months_first_days[i - 1] == first_day and months_first_days[i] == second_day:
				return True
	return False

def main():
	week = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
	first_day = week[input()]
	second_day = week[input()]
	if solveA(first_day, second_day):
		print('YES')
	else:
		print('NO')
main()


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
day1 = input()
day2 = input()
d1 = days.index(day1)
d2 = days.index(day2)
diff = d2 - d1
if diff < 0:
	diff += 7
ans = 'NO'
for month in months:
	if month % 7 == diff:
		ans = 'YES'
		break
print(ans)


monthlist = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
daylist = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
s1 = daylist[input().strip()]
s2 = daylist[input().strip()]
flag = 0
for i in range(11):
	if (monthlist[i] + s1) % 7 == s2:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


s1 = input()
s2 = input()
weekDay = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
n = weekDay[s1]
m = weekDay[s2]
p = (n + 2) % 7
q = (n + 3) % 7
r = n
if p == m or q == m or r == m:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input()
week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
if week[(week.index(s1) + 31) % 7] == s2:
	print('YES')
elif week[(week.index(s1) + 28) % 7] == s2:
	print('YES')
elif week[(week.index(s1) + 30) % 7] == s2:
	print('YES')
else:
	print('NO')


first_day = str(input())
sec_day = str(input())
days_list = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = days_list.index(first_day)
b = days_list.index(sec_day)
s = b - a
if s in [0, 2, 3, -4, -5]:
	print('Yes')
else:
	print('No')


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


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')


def week(m, n):
	if m - n > 0:
		return 7 - m + n
	elif m - n < 0:
		return -m + n
	else:
		return 0
d = {}
d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
m = input()
n = input()
m = d[m]
n = d[n]
if week(m, n) == 3 or week(m, n) == 2 or week(m, n) == 0:
	print('YES')
else:
	print('NO')


week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
l1 = input()
l2 = input()
l1_ = week.index(l1)
week_ = list()
for i in range(l1_, 14):
	week_.append(week[i])
l2_ = week_.index(l2)
if l2_ == 0 or l2_ == 2 or l2_ == 3:
	print('YES')
else:
	print('NO')


s = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday']
a = input()
b = input()
cnt = 0
t = 10 ** 9
r = 10 ** 9
for i in range(9):
	if s[i] == a:
		r = i
		for j in range(i, 10):
			if s[j] == b:
				t = j
				break
		break
if abs(r - t) == 0 or abs(r - t) == 2 or abs(r - t) == 3:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input()
d = {}
if s1 == 'sunday':
	if s2 == 'tuesday' or s2 == 'wednesday' or s2 == 'sunday':
		print('YES')
	else:
		print('NO')
if s1 == 'monday':
	if s2 == 'wednesday' or s2 == 'thursday' or s2 == 'monday':
		print('YES')
	else:
		print('NO')
if s1 == 'tuesday':
	if s2 == 'thursday' or s2 == 'friday' or s2 == 'tuesday':
		print('YES')
	else:
		print('NO')
if s1 == 'wednesday':
	if s2 == 'friday' or s2 == 'saturday' or s2 == 'wednesday':
		print('YES')
	else:
		print('NO')
if s1 == 'thursday':
	if s2 == 'saturday' or s2 == 'sunday' or s2 == 'thursday':
		print('YES')
	else:
		print('NO')
if s1 == 'friday':
	if s2 == 'sunday' or s2 == 'monday' or s2 == 'friday':
		print('YES')
	else:
		print('NO')
if s1 == 'saturday':
	if s2 == 'monday' or s2 == 'tuesday' or s2 == 'saturday':
		print('YES')
	else:
		print('NO')


(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')


weekDays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
dif = [0, 2, 3]
a = input()
b = input()

def verif():
	for i in dif:
		if weekDays[weekDays.index(a) + i] == b:
			print('YES')
			return
	print('NO')
verif()


Days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
Months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
(First, Second) = (input(), input())
for i in range(len(Months) - 1):
	if Days[(Days.index(First) + Months[i]) % 7] == Second:
		print('YES')
		exit()
print('NO')


n = str(input())
b = ('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday')
n = b.index(n)
v = str(input())
print('YES' if v in (b[n], b[(n + 2) % 7], b[(n + 3) % 7]) else 'NO')


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
li = [[['monday', 'monday'], ['monday', 'wednesday'], ['monday', 'thursday']], [['tuesday', 'tuesday'], ['tuesday', 'thursday'], ['tuesday', 'friday']], [['wednesday', 'wednesday'], ['wednesday', 'friday'], ['wednesday', 'saturday']], [['thursday', 'thursday'], ['thursday', 'saturday'], ['thursday', 'sunday']], [['friday', 'friday'], ['friday', 'sunday'], ['friday', 'monday']], [['saturday', 'saturday'], ['saturday', 'monday'], ['saturday', 'tuesday']], [['sunday', 'sunday'], ['sunday', 'tuesday'], ['sunday', 'wednesday']]]
d1 = input()
d2 = input()
ind = days.index(d1)
if li[ind][0][1] == d2 or li[ind][1][1] == d2 or li[ind][2][1] == d2:
	print('YES')
else:
	print('NO')


s = input()
t = input()
A = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
x = A.index(s) + 1
y = A.index(t) + 1
sos = [31 % 7, 30 % 7, 28 % 7]
if (y - x) % 7 in sos:
	print('YES')
else:
	print('NO')


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
monLens = [i % 7 for i in [28, 30, 31]]
daysDiff = -(days.index(input()) - days.index(input())) % 7
if daysDiff in monLens:
	print('YES')
else:
	print('NO')


def compute_possible(day1, day2, month):
	num_days = days_per_month[month]
	val = num_days % 7 + day1
	if val > 7:
		next_month_start_day = val - 7
	else:
		next_month_start_day = val
	return next_month_start_day == day2
days_per_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days_of_the_week = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
first_day = str(input())
second_day = str(input())
first_day_num = days_of_the_week[first_day]
second_day_num = days_of_the_week[second_day]
ans = 'NO'
for m in range(11):
	if compute_possible(first_day_num, second_day_num, m):
		ans = 'YES'
print(ans)


a = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
m1 = a.index(input())
m2 = a.index(input())
if (m2 - m1) % 7 in [0, 2, 3]:
	print('YES')
else:
	print('NO')


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


day_names = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
days = {day_names[i]: i for i in range(len(day_names))}
first = days[input().strip()]
second = days[input().strip()]
cal = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
yup = 'NO'
for month in range(len(cal) - 1):
	if (cal[month] + first) % 7 == second:
		yup = 'YES'
print(yup)


ind = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d1 = ind.index(input())
d2 = ind.index(input())
d2 += 7
diff = (d2 - d1) % 7
if diff == 0 or diff == 2 or diff == 3:
	print('YES')
else:
	print('NO')


def judge(day):
	if day == 'monday':
		return 0
	elif day == 'tuesday':
		return 1
	elif day == 'wednesday':
		return 2
	elif day == 'thursday':
		return 3
	elif day == 'friday':
		return 4
	elif day == 'saturday':
		return 5
	elif day == 'sunday':
		return 6

def cal(day1, day2):
	num = judge(day2) - judge(day1)
	if num < 0:
		num += 7
	return num
first = input()
second = input()
num = cal(first, second)
if num in [0, 2, 3]:
	print('YES')
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')


def main():
	first_day = input()
	second_day = input()
	days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
	first = days.index(first_day)
	possibles = [days[first], days[first + 2 if first < 5 else first - 5], days[first + 3 if first < 4 else first - 4]]
	print('YES' if second_day in possibles else 'NO')
main()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
a = get_string()
b = get_string()
days = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
valid = {0, 2, 3}
if (days[b] - days[a]) % 7 in valid:
	print('YES')
else:
	print('NO')


months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d1 = str(input())
d2 = str(input())
n = days.index(d1)
b = False
for m in months:
	if days[(m + n) % 7] == d2:
		b = True
		break
print('YES' if b else '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')


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')


t1 = input()
t2 = input()
global d
d = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}

def abs(t1, t2):
	if d[t2] - d[t1] >= 0:
		return d[t2] - d[t1]
	else:
		return 7 - d[t1] + d[t2]
if abs(t1, t2) == 3 or abs(t1, t2) == 2 or abs(t1, t2) == 0:
	print('YES')
else:
	print('NO')


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
months = [[31, 28], [28, 31], [31, 30], [30, 31], [31, 31]]
(day1, day2) = (days.index(input()), days.index(input()))
res = 'NO'
for ms in months:
	if (day1 + ms[0] % 7) % 7 == day2:
		res = 'YES'
		break
print(res)


l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
x = input()
y = input()
z = l.index(x)
a = 28 % 7
b = 30 % 7
c = 31 % 7
if l[z + a] == y or l[z + b] == y or l[z + c] == y:
	print('YES')
else:
	print('NO')


day = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = day.index(str(input()))
b = day.index(str(input()))
ans = 'NO'
if (b - a) % 7 in [3, 0, 2]:
	ans = 'YES'
print(ans)


w = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su']
exec('a,b=[' + 2 * 'w.index(input()[:2]),' + ']')
print('YNEOS'[all(((a + x) % 7 != b for x in [0, 2, 3]))::2])


s1 = input()
s2 = input()
index = 0
a = {1: 'monday', 2: 'tuesday', 3: 'wednesday', 4: 'thursday', 5: 'friday', 6: 'saturday', 7: 'sunday', 8: 'monday', 9: 'tuesday', 10: 'wednesday', 11: 'thursday', 12: 'friday', 13: 'saturday', 14: 'sunday'}
for i in range(1, 15):
	if a[i] == s1:
		index = i
		break
if s2 == a[index] or s2 == a[index + 3] or s2 == a[index + 2]:
	print('YES')
else:
	print('NO')


q = input('')
w = input('')
t = 0
if q == 'monday':
	e = 1
elif q == 'tuesday':
	e = 2
elif q == 'wednesday':
	e = 3
elif q == 'thursday':
	e = 4
elif q == 'friday':
	e = 5
elif q == 'saturday':
	e = 6
else:
	e = 7
if w == 'monday':
	r = 1
elif w == 'tuesday':
	r = 2
elif w == 'wednesday':
	r = 3
elif w == 'thursday':
	r = 4
elif w == 'friday':
	r = 5
elif w == 'saturday':
	r = 6
else:
	r = 7
if e == r:
	t = 1
elif e == r - 2:
	t = 1
elif e == r - 3:
	t = 1
elif e == r + 5:
	t = 1
elif e == r + 4:
	t = 1
if t == 1:
	print('YES')
else:
	print('NO')


d1 = input()
d2 = input()
if d1 == 'monday':
	if d2 == 'monday' or d2 == 'wednesday' or d2 == 'thursday':
		print('YES')
	else:
		print('NO')
if d1 == 'tuesday':
	if d2 == 'tuesday' or d2 == 'thursday' or d2 == 'friday':
		print('YES')
	else:
		print('NO')
if d1 == 'wednesday':
	if d2 == 'wednesday' or d2 == 'friday' or d2 == 'saturday':
		print('YES')
	else:
		print('NO')
if d1 == 'thursday':
	if d2 == 'thursday' or d2 == 'saturday' or d2 == 'sunday':
		print('YES')
	else:
		print('NO')
if d1 == 'friday':
	if d2 == 'friday' or d2 == 'sunday' or d2 == 'monday':
		print('YES')
	else:
		print('NO')
if d1 == 'saturday':
	if d2 == 'saturday' or d2 == 'monday' or d2 == 'tuesday':
		print('YES')
	else:
		print('NO')
if d1 == 'sunday':
	if d2 == 'sunday' or d2 == 'tuesday' or d2 == 'wednesday':
		print('YES')
	else:
		print('NO')


def checking_the_calendar():
	months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
	text = input()
	text += input()
	for i in range(7):
		res = days[i]
		next_day = i
		for j in range(11):
			next_day += months[j]
			next_day = next_day % 7
			res += days[next_day]
		if text in res:
			return 'YES'
	return 'NO'
print(checking_the_calendar())


n1 = input()
n2 = input()
l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = l.index(n1)
b = l.index(n2)
if b >= a:
	x = b - a
	if x == 0 or x == 2 or x == 3:
		print('YES')
	else:
		print('NO')
else:
	x = 6 - a + (b + 1)
	if x == 0 or x == 2 or x == 3:
		print('YES')
	else:
		print('NO')


d = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
dayone = input()
daytwo = input()
oneint = d[dayone]
twoint = d[daytwo]
if oneint == twoint:
	print('YES')
elif (oneint + 2) % 7 == twoint:
	print('YES')
elif (oneint + 3) % 7 == twoint:
	print('YES')
else:
	print('NO')


days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(d1, d2) = (input(), input())
if (days.index(d2) + 7 - days.index(d1)) % 7 in [0, 2, 3]:
	print('YES')
else:
	print('NO')


def main():
	from sys import stdin, stdout
	dayNum = {'saturday': 0, 'sunday': 1, 'monday': 2, 'tuesday': 3, 'wednesday': 4, 'thursday': 5, 'friday': 6}
	(day1, day2) = tuple(stdin.read().split())
	day1 = dayNum[day1]
	day2 = dayNum[day2]
	stdout.write('YES\n' if (day1 + 28) % 7 == day2 or (day1 + 30) % 7 == day2 or (day1 + 31) % 7 == day2 else 'NO\n')
main()


days_name = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
first_day_number = days_name.index(input())
second_day_number = days_name.index(input())
for number in [28, 30, 31]:
	if (number + first_day_number - 28) % 7 == second_day_number:
		print('YES')
		exit()
print('NO')


l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
x = input()
y = input()
f = []
for n in [28, 30, 31]:
	d = n % 7
	f.append(d)
c = l.index(x)
v = l.index(y)
for i in range(3):
	f[i] += c
	f[i] = f[i] % 7
if v in f:
	print('YES')
else:
	print('NO')


day = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d1 = input()
d2 = input()
k = day.index(d2) - day.index(d1)
if k < 0:
	k = 7 + k
if k == 0 or k == 2 or k == 3:
	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')


M = ('mo', 'tu', 'we', 'th', 'fr', 'sa', 'su')
n = (M.index(input()[:2]) - M.index(input()[:2])) % len(M)
print('YES' if 1 > n or 3 < n < 6 else 'NO')


s = input()
s1 = input()
if s == 'monday' and (s1 == 'thursday' or s1 == 'wednesday' or s1 == 'monday'):
	print('YES')
elif s == 'tuesday' and (s1 == 'friday' or s1 == 'thursday' or s1 == 'tuesday'):
	print('YES')
elif s == 'wednesday' and (s1 == 'saturday' or s1 == 'friday' or s1 == 'wednesday'):
	print('YES')
elif s == 'thursday' and (s1 == 'sunday' or s1 == 'saturday' or s1 == 'thursday'):
	print('YES')
elif s == 'friday' and (s1 == 'monday' or s1 == 'sunday' or s1 == 'friday'):
	print('YES')
elif s == 'saturday' and (s1 == 'tuesday' or s1 == 'monday' or s1 == 'saturday'):
	print('YES')
elif s == 'sunday' and (s1 == 'wednesday' or s1 == 'tuesday' or s1 == 'sunday'):
	print('YES')
else:
	print('NO')


d = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
l_n = list([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31])
x = input()
y = input()
for i in range(0, 11):
	if (l_n[i] + d[x]) % 7 == d[y]:
		print('YES')
		quit()
print('NO')


il = [4, 7, 7, 3, 5, 1, 3, 6, 2, 4, 7, 2]
id = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
(a, b) = (id.get(input()), id.get(input()))
ans = False
for i in range(11):
	if il[i] - a == il[i + 1] - b:
		ans = True
		break
print(['NO', 'YES'][ans])


v = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = input()
b = input()
q = v.index(a)
f = 0
z = [q, q + 3, q + 2]
for i in z:
	if v[i % 7] == b:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


import sys, re, itertools
_use_stdin = True
if _use_stdin:
	inp = sys.stdin
else:
	inp = open('input.txt', 'r')
ls = inp.read().splitlines()
ws = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(w1, w2) = (ws.index(ls[0]), ws.index(ls[1]))
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

def next(m, first):
	return (first + days[m] + 1) % 7
flag = True

def f(m):
	s = ''
	for i in range(days[m] + 1):
		s = ws[(w1 + i) % 7]
	return s
f(1)
for i in range(11):
	if ls[1] == f(i):
		print('YES')
		flag = False
		break
if flag:
	print('NO')


array = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday']
x = input()
y = input()
if x == y:
	print('YES')
else:
	for i in range(len(array)):
		try:
			if x == array[i] and y == array[i + 2]:
				print('YES')
				break
			elif x == array[i] and y == array[i + 3]:
				print('YES')
				break
		except:
			pass
	else:
		print('NO')


__author__ = 'artyom'

def main():
	c = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
	a = c.index(read(0))
	b = c.index(read(0))
	d = b - a if a <= b else 7 - a + b
	return d in [0, 2, 3]

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s)
write(['NO', 'YES'][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')


import sys
import time
import itertools
import math

def inp():
	ln = input().split()
	return int(ln[0]) if len(ln) == 1 else [int(i) for i in ln]

def prl(x):
	print(' '.join([str(i) for i in x]))
l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
first = input()
second = input()
f = l.index(first)
s = l.index(second)
print(['NO', 'YES'][(s - f) % 7 in [0, 2, 3]])


FirstDay = input()
SecondDay = input()
WeekDay = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
NumOfFirstDay = WeekDay.index(FirstDay)
NumOfSecondDay = WeekDay.index(SecondDay)
NumOfMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
Cur = NumOfFirstDay
flag = False
for k in range(7):
	if flag:
		break
	for i in range(12):
		Cur = NumOfFirstDay
		NumOfFirstDay += int(NumOfMonth[i]) % 7
		NumOfFirstDay %= 7
		if Cur == WeekDay.index(FirstDay) and NumOfFirstDay == NumOfSecondDay:
			print('YES')
			flag = True
			break
else:
	print('NO')


a = str(input())
b = str(input())
k = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
a = k[a] - 1
b = k[b] - 1
res = False
res = res or ((a + 2) % 7 + 1) % 7 == b
res = res or ((a + 1) % 7 + 1) % 7 == b
res = res or ((a + 6) % 7 + 1) % 7 == b
if res:
	print('YES')
else:
	print('NO')


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
MOD = 10 ** 9 + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	c = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
	a = c.index(input())
	b = c.index(input())
	if a > b:
		b += 7
	if b - a == 2 or b - a == 3 or a == b:
		print('YES')
	else:
		print('NO')
main()


s1 = input()
s2 = input()
a = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']
for i in range(7):
	if a[i] == s1:
		d1 = i
	if a[i] == s2:
		d2 = i
if (d1 + 31 % 7) % 7 == d2 or (d1 + 30 % 7) % 7 == d2 or (d1 + 28 % 7) % 7 == d2:
	print('YES')
else:
	print('NO')


from calendar import day_name
DAY_NAME = list(day_name)
f = lambda : DAY_NAME.index(input().title())
print('YES' if (f() - f()) % 7 in (0, 4, 5) 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')


FirstDay = input()
SecondDay = input()
ListOfDays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
if FirstDay in ListOfDays:
	a = ListOfDays.index(str(FirstDay))
if SecondDay in ListOfDays:
	b = ListOfDays.index(str(SecondDay))
o = [a, a + 2, a + 3, a - 4, a - 5]
if b in o:
	print('YES')
else:
	print('NO')


week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
(a, b) = (input(), input())
tmp = [0, 2, 3]
x = week.index(b) - week.index(a)
if x % 7 in tmp:
	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')


s = input()
s1 = input()

def getnum(s):
	if s == 'monday':
		return 0
	elif s == 'tuesday':
		return 1
	elif s == 'wednesday':
		return 2
	elif s == 'thursday':
		return 3
	elif s == 'friday':
		return 4
	elif s == 'saturday':
		return 5
	else:
		return 6
n = getnum(s)
n1 = getnum(s1)
a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(10):
	if (n + a[i]) % 7 == n1:
		print('YES')
		exit(0)
print('NO')


import math
import os
import random
import re
import sys
import functools
import datetime as dt
from operator import itemgetter, attrgetter
from collections import Counter
Y = lambda : list(map(int, input().split()))
P = lambda : map(int, input().split())
N = lambda : int(input())
a = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
c = input()
n = input()
print('YNEOS'[not (a.index(n) - a.index(c) + 7) % 7 in (0, 2, 3)::2])


s1 = input()
s2 = input()
p = dict(zip(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'], [1, 2, 3, 4, 5, 6, 7]))
a1 = int(p[s1])
a2 = int(p[s2])
if a2 < a1:
	a2 += 7
j = a2 - a1
if j == 3 or j == 2 or j == 0:
	print('YES')
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')
		exit()
print('NO')


a = input()
b = input()
(p1, p2) = (0, 0)
D = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(7):
	if D[i] == a:
		p1 = i
	if D[i] == b:
		p2 = i
B = False
for i in range(len(d) - 1):
	S = (p1 + d[i] % 7) % 7
	if S == p2:
		B = True
		break
if B:
	print('YES')
if B == False:
	print('NO')


def main():
	d = {'monday': 6, 'tuesday': 5, 'wednesday': 4, 'thursday': 3, 'friday': 2, 'saturday': 1, 'sunday': 0}
	dif = (d[input()] - d[input()]) % 7
	print(('NO', 'YES')[any((a % 7 == dif for a in (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)))])
main()


from sys import stdin

def main():
	a = stdin_get_string_from_line()
	b = stdin_get_string_from_line()
	x = {'monday': 1, 'tuesday': 2, 'wednesday': 3, 'thursday': 4, 'friday': 5, 'saturday': 6, 'sunday': 7}
	if x[b] - x[a] in [-5, -4, 0, 2, 3]:
		print('YES')
	else:
		print('NO')
	return

def stdin_get_ints_from_line():
	return (int(x) for x in stdin.readline().strip().split(' '))

def stdin_get_ints_list_from_line():
	return list((int(x) for x in stdin.readline().strip().split(' ')))

def stdin_get_string_from_line():
	return stdin.readline().strip()
main()


from math import fabs
a = input()
b = input()
if a == 'monday':
	a = 1
elif a == 'tuesday':
	a = 2
elif a == 'wednesday':
	a = 3
elif a == 'thursday':
	a = 4
elif a == 'friday':
	a = 5
elif a == 'saturday':
	a = 6
else:
	a = 7
if b == 'monday':
	b = 1
elif b == 'tuesday':
	b = 2
elif b == 'wednesday':
	b = 3
elif b == 'thursday':
	b = 4
elif b == 'friday':
	b = 5
elif b == 'saturday':
	b = 6
else:
	b = 7
s = a - b
if s == 0 or s == 4 or s == -3 or (s == -2) or (s == 5):
	print('YES')
else:
	print('NO')


Input = lambda : map(int, input().split())
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
a = input()
b = input()
if a == b:
	print('YES')
	exit()
y = days.index(a)
y = (y + 3) % 7
if b == days[y]:
	print('YES')
	exit()
y = days.index(a)
y = (y + 2) % 7
print('YES' if b == days[y] else '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')


m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
d = 0
s1 = input()
s2 = input()
week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
s1 = week.index(s1)
s2 = week.index(s2)
z = abs(s1 - s2)
log = False
for d in range(7):
	summ = m[0] + d
	for i in range(1, 12):
		q = summ % 7
		summ += m[i]
		w = summ % 7
		if q == s1 and w == s2:
			log = True
if log:
	print('YES')
else:
	print('NO')


def check(days, start, end):
	total = 0
	while total < days:
		start += 1
		if start == 7:
			start = 0
		total += 1
	if start == end:
		return True
	return False

def main1():
	days = {}
	days['monday'] = 0
	days['tuesday'] = 1
	days['wednesday'] = 2
	days['thursday'] = 3
	days['friday'] = 4
	days['saturday'] = 5
	days['sunday'] = 6
	n1 = days[input()]
	n2 = days[input()]
	if check(30, n1, n2) or check(31, n1, n2) or check(28, n1, n2):
		print('YES')
		return
	print('NO')
main1()


days = set([31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31])
week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
d1 = week.index(input())
d2 = week.index(input())
found = False
for d in days:
	if (d1 - d2 + d) % len(week) == 0:
		found = True
		break
if found:
	print('YES')
else:
	print('NO')


def get_day_number(s):
	if s == 'monday':
		return 1
	elif s == 'tuesday':
		return 2
	elif s == 'wednesday':
		return 3
	elif s == 'thursday':
		return 4
	elif s == 'friday':
		return 5
	elif s == 'saturday':
		return 6
	elif s == 'sunday':
		return 7
first_day = get_day_number(input())
second_day = get_day_number(input())
if (second_day - first_day) % 7 in {0, 3, 2}:
	print('YES')
else:
	print('NO')


d = {'monday': 0, 'tuesday': 1, 'wednesday': 2, 'thursday': 3, 'friday': 4, 'saturday': 5, 'sunday': 6}
f = d[input()]
s = d[input()]
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(11):
	(cf, cs) = (months[i], months[i + 1])
	if (cf + f) % 7 == s:
		print('YES')
		break
else:
	print('NO')


week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
days = [31, 28, 31, 30, 31]
m1 = week.index(input())
m2 = week.index(input())
b = False
for i in days:
	if (m1 + i) % 7 == m2:
		b = True
		break
if b:
	print('YES')
else:
	print('NO')


(monday, tuesday, wednesday, thursday, friday, saturday, sunday) = range(7)
week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
day1 = input()
day2 = input()
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
f = 0
s = 0
for i in range(7):
	if week[i] == day1:
		f = i
	if week[i] == day2:
		s = i

def next_week(first, second):
	for month in months:
		if (first + (month - 28)) % 7 == second:
			return True
	return False
if next_week(f, s):
	print('YES')
else:
	print('NO')


dw = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
print('YES' if (-dw.index(input()) + dw.index(input()) + 7) % 7 in (0, 2, 3) else 'NO')


w1 = input()
w2 = input()

def w_to_num(w):
	to_num = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
	return to_num.index(w)
n1 = w_to_num(w1)
n2 = w_to_num(w2)
for m in [28, 30, 31]:
	if (n1 + m) % 7 == n2:
		print('YES')
		break
else:
	print('NO')


a = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
s = input()
t = input()
for i in range(14):
	if a[i] == s:
		if a[i] == t or a[i + 2] == t or a[i + 3] == t:
			print('YES')
		else:
			print('NO')
		break


dias_mes = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
dias = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
cadena_dia_1 = input()
cadena_dia_2 = input()
for i in range(7):
	if cadena_dia_1 == dias[i]:
		dia1 = i
	if cadena_dia_2 == dias[i]:
		dia2 = i
anio = 2010
encontrado = False
dia_mes_1 = 4
while anio < 2020 and (not encontrado):
	mes = 0
	while mes < 11:
		dia_mes_2 = (dia_mes_1 + dias_mes[mes]) % 7
		if dia_mes_1 == dia1 and dia_mes_2 == dia2:
			encontrado = True
			break
		else:
			dia_mes_1 = dia_mes_2
		mes = mes + 1
	dia_mes_1 = dia_mes_2
	anio = anio + 1
	if anio % 4 == 0:
		anio = anio + 1
if encontrado:
	print('YES')
else:
	print('NO')


a1 = str(input())
a2 = str(input())
l = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
ind = l.index(a1)
if a2 in [l[ind], l[(ind + 3) % 7], l[(ind + 2) % 7]]:
	print('YES')
else:
	print('NO')


d1 = input()
d2 = input()
if d1[0] == 'm':
	dd1 = 1
if d1[0] == 't':
	if d1[1] == 'u':
		dd1 = 2
	else:
		dd1 = 4
if d1[0] == 'w':
	dd1 = 3
if d1[0] == 'f':
	dd1 = 5
if d1[0] == 's':
	if d1[1] == 'a':
		dd1 = 6
	else:
		dd1 = 0
if d2[0] == 'f':
	dd2 = 5
if d2[0] == 'm':
	dd2 = 1
if d2[0] == 't':
	if d2[1] == 'u':
		dd2 = 2
	else:
		dd2 = 4
if d2[0] == 'w':
	dd2 = 3
if d2[0] == 's':
	if d2[1] == 'a':
		dd2 = 6
	else:
		dd2 = 0
if (dd1 + 30) % 7 == dd2 or (dd1 + 31) % 7 == dd2 or (dd1 + 28) % 7 == dd2:
	print('YES')
else:
	print('NO')


first = input()
second = input()
arr = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
days_of_year = [32, 29, 32, 31, 32, 31, 32, 32, 31, 32, 31, 32]
dayArr = []
orderFirst = 0
orderSecond = 0
for i in range(len(arr)):
	if arr[i] == first:
		orderFirst = i
	if arr[i] == second:
		orderSecond = i
for j in range(len(days_of_year)):
	x = orderFirst
	for z in range(days_of_year[j]):
		dayArr.append(x % 7)
		x += 1
	if dayArr[0] == orderFirst and dayArr[len(dayArr) - 1] == orderSecond:
		print('YES')
		exit()
	dayArr = []
print('NO')


one = input()
two = input()
days = {el: i for (i, el) in enumerate(('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'), 1)}
delta = (days[two] - days[one]) % 7
print(('NO', 'YES')[delta in {0, 2, 3}])


day1 = input()
day2 = input()
days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30]
listik = []

def pryntfirstdays():
	daysmega = 100 * days
	for a in range(7):
		mnam = [daysmega[0 + a]]
		f = a
		for bay in months:
			f += bay
			mnam.append(daysmega[f])
		listik.append(mnam)
	return listik
listik = pryntfirstdays()
bol = 'NO'
for year in listik:
	a = -1
	for firstday in year:
		a += 1
		if firstday == day1:
			if a != 11:
				if year[a + 1] == day2:
					bol = 'YES'
print(bol)


s = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
I = input
a = I()
print(['NO', 'YES'][I() in [s[(s.index(a) + i) % 7] for i in (28, 30, 31)]])


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


D = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
week = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
week += week
Y1 = input()
Y2 = input()
(s, t) = (-1, -1)
for i in range(7):
	if Y1 == week[i]:
		s = i
for i in range(s, 14):
	if Y2 == week[i]:
		t = i
d = (t - s) % 7
for i in range(11):
	if D[i] % 7 == d:
		print('YES')
		exit()
print('NO')


S = input()
S1 = input()
if S == 'monday':
	k = 1
if S == 'tuesday':
	k = 2
if S == 'wednesday':
	k = 3
if S == 'thursday':
	k = 4
if S == 'friday':
	k = 5
if S == 'saturday':
	k = 6
if S == 'sunday':
	k = 7
if S1 == 'monday':
	k1 = 1
if S1 == 'tuesday':
	k1 = 2
if S1 == 'wednesday':
	k1 = 3
if S1 == 'thursday':
	k1 = 4
if S1 == 'friday':
	k1 = 5
if S1 == 'saturday':
	k1 = 6
if S1 == 'sunday':
	k1 = 7
if k <= k1:
	if abs(k - k1) == 0 or abs(k - k1) == 2 or abs(k - k1) == 3:
		print('YES')
	else:
		print('NO')
else:
	v = 7 - k + 1
	k = 1
	k1 = k1 + v
	if abs(k - k1) == 0 or abs(k - k1) == 2 or abs(k - k1) == 3:
		print('YES')
	else:
		print('NO')