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) -> [|(x,y); (y,x)|].(n mod 2)))
