Scanf.scanf "%d %d %d" (fun a b c -> let calc rest cost = let rec loop i = if i > cost then max_int else let r2 = rest + (cost - i) / 10 + (cost - i) mod 10 in if r2 = c then i else loop (i + 1) in loop 1 in let rec loop_i i acc = let rec loop_j j acc = if j > a then acc else let rest = calc (b - i + a - j) (i * 10 + j) in loop_j (j + 1) (min acc rest) in if i > b then acc else loop_i (i + 1) (loop_j 0 acc) in let ans = loop_i 0 max_int in if ans = max_int then print_endline "Impossible" else Printf.printf "%d\n" ans )