let R() = stdin.ReadLine() let (|Number|_|) n = match System.Int32.TryParse n with | true, x -> let inRange = 0 <= x && x <= 12345 let hasLeadingZero = let raw = n let trimed = match n with | "0" -> "0" | _ -> n.TrimStart('0') raw <> trimed if inRange && not hasLeadingZero then Some(x) else None | _ -> None let A = R() let B = R() match A, B with | Number x, Number y -> "OK" | _ -> "NG" |> printfn "%s"