
let _ = 
  let num_mon = [0;31;29;31;30;31;30;31;31;30;31;30] in
  let rec take n = function
    | [] -> []
    | hd :: tl when n = 0 -> []
    | hd :: tl -> hd :: take (n - 1) tl in
  let num_of_day m d = List.fold_left (+) 0 (take m num_mon) + d in
  let whatday m d =
    match num_of_day m d mod 7 with
    | 0 -> "Wednesday"
    | 1 -> "Thursday"
    | 2 -> "Friday"
    | 3 -> "Saturday"
    | 4 -> "Sunday"
    | 5 -> "Monday"
    | 6 -> "Tuesday"
    | _ -> failwith "whatday" in
  try 
    while true do
      let m, d = Scanf.scanf "%d %d\n" (fun m d -> (m, d)) in
      if m = 0 then raise End_of_file else print_endline @@ whatday m d
    done
  with
    End_of_file -> ()