let main stdin = let rec str_to_list str i split list = if i > String.length str then list else let p = (try String.index_from str i split with Not_found -> String.length str) in let word = String.sub str i (p-i) in str_to_list str (p+1) split (word :: list) in let waketime n h m t = let minute_to_hour m = (m / 60) mod 24 in let rec wakeminutes n' m' = if n' = 1 then (* h hour m minute で一回めざまし止める *) let hour = minute_to_hour m' in let minute = m' mod 60 in Printf.printf "%d\n%d\n" hour minute else wakeminutes (n'- 1) (m' + t) in wakeminutes n (h * 60 + m) in match str_to_list stdin 0 ' ' [] with [t;m;h;n] -> waketime (int_of_string n) (int_of_string h) (int_of_string m) (int_of_string t)