data Weekday = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday deriving (Show,Eq,Enum)

main = do
    str <- getLine
    if str == "0 0" then return ()
                    else do
                        let [month,day] = map read.words $ str
                        print $ getWeekday 2 month day
                        main

daysOfMonth :: [Int]
daysOfMonth = [31,29,31,39,31,30,31,31,30,31,30,31]

getWeekday :: Int -> Int -> Int -> Weekday
getWeekday offset month day = toEnum $ ((elapsedDay `mod` 7) + offset) `mod` 7
    where elapsedDay = day + (sum.take (month-1) $ daysOfMonth)