let rec fold_n n f a k = if n <= 0 then k a else fold_n (n-1) f (f a) k
let f (a, b) = (b + a/2, a/2)
let _ = Scanf.scanf "%d %d %d" @@ fun a b n ->
  fold_n n f (a, b) @@ fun (x,y) ->
  if n mod 2 = 0 then Printf.printf "%d %d\n" x y
  else Printf.printf "%d %d\n" y x
