Scanf.scanf "%d %d %d" (fun a b k ->
    let rec loop a b r =
        if r = 0 then (if k mod 2 = 0 then Printf.printf "%d %d\n" a b
                                      else Printf.printf "%d %d\n" b a)
        else
            let c = a / 2 in
            loop (b + c) (a / 2 * 2 - c) (r - 1)
    in
    loop a b k
)