list :: [Int]
list = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

youbi :: [String]
youbi = ["Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"]

solve :: [[Int]] -> [String]
solve [] = []
solve ([a,b]:xs) = ((!!) youbi $ flip mod 7 $ (+) b $ sum $ take (a-1) list) :\
 solve xs

main = getContents >>= mapM_ putStrLn . solve . map (map read . words) . init . lines
