let ext_euclid a b =
  let rec doit a b x y =
    if b = 0 then (1, 0, a)
    else
      let (y, x, d) = doit b (a mod b) x y in
      (x, y - (a / b) * x, d) in
  doit a b 0 0 |> (fun (x, y, _) -> (x, y))

let () =
  let (a, b) = Scanf.scanf "%d %d\n" (fun a b -> (a, b)) in
  let (x, y) = ext_euclid a b in
  Printf.printf "%d %d\n" x y