s = eval(input())

print((['', 'SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN'].index(s)))
print((7-['SUN','MON','TUE','WED','THU','FRI','SAT'].index(eval(input()))))
s = eval(input())
print((["", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"].index(s)))

print((7 - ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].index(eval(input()))))

-s = eval(input()) -print((["", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"].index(s))) +print((7 - ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"].index(eval(input()))))