let doIt () = let shour, dh = stdin.ReadLine () |> fun str -> str.Split () |> fun arr -> (arr.[0], int arr.[1]) let hour = match shour with | "IX" -> 9 | s -> seq s |> Seq.map (function | 'I' -> 1 | 'V' -> 5 | _ -> 10) |> Seq.sum (hour + (dh % 12) + 12) % 12 |> (function | 0 -> 12 | n -> n) |> (function | n when n <= 4 -> System.String('I', n) | n when n <= 8 -> "V" + System.String('I', n - 5) | 9 -> "IX" | n -> "X" + System.String('I', n - 10)) |> printfn "%s" doIt ()