main = interact $ unlines . map (today2004 . map read) . takeWhile (notElem "0") . map words . lines
today2004 [m,d] = case (mod days 7) of {0->"Wednesday";1->"Thursday";2->"Friday";3->"Saturday";4->"Sunday";5->"Monday";6->"Tuesday"}
 where days = (sum $ take (m-1) [31,29,31,30,31,30,31,31,30,31,30,31]) + d