# This inputs a date m d y and prints the day of the
# week that date occurred on.

def yearCalendar(y):
    # This prints the 12 month calendars for year y
    print( "The yearCalendar function is not yet implemented." )
        
def monthCalendar(m, y):
    # This prints a calendar for month m of year y
    print( "The monthCalendar function is not yet implemented." )
    num = daysInMonth(m,y)
    lineCount = 0
    for day in range(1, num+1):
        print("%5d"%day, end=" ")
        lineCount = lineCount + 1
        if lineCount == 7:
            print()
            lineCount = 0
        

def monthName(m):
    if m == 1:
        return "January"
    elif m == 2:
        return "February"
    elif m == 3:
        return "March"
    elif m == 4:
        return "April"
    elif m == 5:
        return "May"
    elif m == 6:
        return "June"
    elif m == 7:
        return "July"
    elif m == 8:
        return "August"
    elif m == 9:
        return "September"
    elif m == 10:
        return "October"
    elif m == 11:
        return "November"
    elif m == 12:
        return "December"
    else:
        return "Bad month"

def isLeapYear(y):
    # This returns True or False depending oon
    #  whether y is a leap year
    if y%400 == 0:
        return True
    elif y%100 == 0:
        return False
    elif y%4 == 0:
        return True
    else:
        return False
    
def daysInMonth(m, y):
    # This returns 31 for January (month 1),
    # 28 or 29 for February (month 2), etc.
    if m == 1:
        return 31
    elif m == 2:
        if isLeapYear(y):
            return 29
        else:
            return 28
    elif m == 3:
        return 31
    elif m == 4:
        return 30
    elif m == 5:
        return 31
    elif m == 6:
        return 30
    elif m == 7:
        return 31
    elif m == 8:
        return 31
    elif m == 9:
        return 30
    elif m == 10:
        return 31
    elif m == 11:
        return 30
    elif m == 12:
        return 31
    else:
        print( "Bad Month" )
        return 0
    
def DayName(d):
    # This returns the name of day d: "Sunday" for 0
    # "Monday" for 1, etc.
    if d == 0:
        return "Sunday"
    elif d == 1:
        return "Monday"
    elif d == 2:
        return "Tuesday"
    elif d == 3:
        return "Wednesday"
    elif d == 4:
        return "Thursday"
    elif d == 5:
        return "Friday"
    elif d == 6:
        return "Saturday"
    else:
        return "BadDayName"

def yearDays(y):
    # This returns the number of days of all of the
    # years from 1800 up to but not including y
    total = 0
    for year in range(1800, y):
        if isLeapYear(year):
            total = total + 366
        else:
            total = total + 365
    return total


def monthDays(m, y):
    # This returns the number of days of all of the
    # months of year y prior to m.
    total = 0
    for month in range(1, m):
        total = total + daysInMonth( month, y )
    return total
    
    

def daysSince1800(m, d, y):
    # this returns the number of days between 1,1,1800
    # and m,d,y
    total = yearDays(y)+monthDays(m, y)+d-1
    return total

def dayOfWeek(m, d, y):
    # This returns 0 for a Sunday, 1 for a Monday, etc.
    total = daysSince1800(m, d, y)
    rem = total%7
    if rem == 0:
        return 3 # Wednesday
    elif rem == 1:
        return 4
    elif rem == 2:
        return 5
    elif rem == 3:
        return 6
    elif rem == 4:
        return 0
    elif rem == 5:
        return 1
    elif rem == 6:
        return 2
    else:
        print( "I'm confused.")
        return -1
    
def printDay(m, d, y):
    # This prints the name of the date m, d, y
    # such as "Friday" for 2, 19, 2016
    # Note that Jan 1, 1800 was a Wednesday
    day = dayOfWeek(m, d, y) # That returns 0 for Sun, 1 for Mon, etc
    print( "That was a %s"%DayName(day) )
    
    
def main():
    done = False
    while not done:
        line = input( "Enter a date m d y: " )
        if line == "":
            done = True
        else:
            fields = line.split()
            if len(fields) == 3:
                ms, ds, ys = fields
                month = eval(ms)
                day = eval(ds)
                year = eval(ys)
                printDay(month, day, year)
            elif len(fields) == 2:
                ms, ys = fields
                month = eval(ms)
                year = eval(ys)
                monthCalendar(month, year)
            elif len(fields) == 1:
                ys, = fields
                year = eval(ys)
                yearCalendar(year)

main()
