open Unix;;
let get_time m d y =
  snd (Unix.mktime {
      Unix.tm_sec = 0;
      tm_min = 0;
      tm_hour = 0;
      tm_mday = d;
      tm_mon = m-1;
      tm_year = y-1900;
      tm_wday = (-1);
      tm_yday = (-1);
      tm_isdst=false;
    }) ;;

let () =
  let print_wday w =
    let wday =
      match w with
        0 -> "Sunday"
      | 1 -> "Monday"
      | 2 -> "Tuesday"
      | 3 -> "Wednesday"
      | 4 -> "Thursday"
      | 5 -> "Friday"
      | 6 -> "Saturday"
      | _ -> "Whatever"
    in print_endline wday
  in
  let rec read () =
    let a = read_line () |> Str.split (Str.regexp " ")
            |> List.map int_of_string |> Array.of_list
    in
    match (a.(0), a.(1)) with
      (0, 0) -> ()
    | (m, d) ->
       let t = get_time m d 2004
       in
       print_wday (let open Unix in t.tm_wday);read ()
  in read ()
;;