open Batteries
let n, k = Scanf.sscanf (read_line()) "%d %d" (fun n k -> n, k)
let h = Array.init n (fun a -> Scanf.scanf " %d" @@ fun b -> b)

let dp = Array.init 100010 @@ fun a -> max_int
let _ = dp.(0) <- 0

let change i w =
  if dp.(i) > dp.(i-w) + (abs @@ h.(i) - h.(i-w)) then dp.(i) <- dp.(i-w) + (abs @@ h.(i) - h.(i-w))

let rec loop i =
  if i >= n then dp.(n-1) else (
    change i 1;
    if i > 1 then
    let rec loop2 i2 =
      if i2 > k || -1 >= (i - i2) then () else (change i i2; loop2 (i2+1))
    in loop2 2
     else ();
    loop (i+1)
    )

let _ = Printf.printf "%d\n" @@ loop 1

Score : 100 points

Problem Statement

There are N stones, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), the height of Stone i is h_i.

There is a frog who is initially on Stone 1.
He will repeat the following action some number of times to reach Stone N:

If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on.

Find the minimum possible total cost incurred before the frog reaches Stone N.

Constraints

All values in input are integers.

2 \leq N \leq 10^5

1 \leq K \leq 100

1 \leq h_i \leq 10^4

Input

Input is given from Standard Input in the following format:

N K
h_1 h_2 \ldots h_N

Output

Print the minimum possible total cost incurred.

Sample Input 1

5 3
10 30 40 50 20

Sample Output 1

30

If we follow the path 1 → 2 → 5, the total cost incurred would be |10 - 30| + |30 - 20| = 30.

Sample Input 2

3 1
10 20 10

Sample Output 2

20

If we follow the path 1 → 2 → 3, the total cost incurred would be |10 - 20| + |20 - 10| = 20.

Sample Input 3

2 100
10 10

Sample Output 3

0

If we follow the path 1 → 2, the total cost incurred would be |10 - 10| = 0.

Sample Input 4

10 4
40 10 20 70 80 10 20 70 80 60

Sample Output 4

40

If we follow the path 1 → 4 → 8 → 10, the total cost incurred would be |40 - 70| + |70 - 70| + |70 - 60| = 40.


let cost k cs xs y =
    let rec cost_sub k cs xs y m =
        match cs, xs with
        | c :: cs', x :: xs' when k > 0 ->
                cost_sub (k - 1) cs' xs' y (min m (c + abs (y - x)))
        | _ -> m
    in cost_sub k cs xs y max_int

let rec solve k cs xs ys =
    match ys with
    | y :: ys' ->
            let c = cost k cs xs y in
            solve k (c :: cs) (y :: xs) ys'
    | [] -> List.hd cs

let () =
    let line = read_line () in
    let k = Scanf.sscanf line "%d %d" (fun _ k -> k) in
    let h =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
    in
    match h with
    | x :: xs ->
            print_int (solve k [0] [x] xs);
            print_newline ()
    | _ -> ()

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


let rec take n xs =
    match xs with
    | x :: xs' when n > 0 -> x :: take (n - 1) xs'
    | _ -> []

let rec cost k cs xs y =
    let cs' = take k cs in
    let xs' = take k xs in
    List.fold_left2 (fun m c x -> min m (c + abs (y - x))) max_int cs' xs'

let rec solve k cs xs ys =
    match ys with
    | y :: ys' ->
            let c = cost k cs xs y in
            solve k (c :: cs) (y :: xs) ys'
    | [] -> List.hd cs

let () =
    let k =
        let line = read_line () in
        Scanf.sscanf line "%d %d" (fun _ k -> k)
    in
    let h =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string
    in
    match h with
    | x :: xs ->
            print_int (solve k [0] [x] xs);
            print_newline ()
    | _ -> ()


let kInf = 1 lsl 60
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let hs = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let dp = Array.make n kInf
let _ =
  dp.(0) <- 0;
  for i = 1 to n - 1 do
    for j = 1 to k do
      if i >= j then dp.(i) <- min dp.(i) @@ dp.(i - j) + abs (hs.(i) - hs.(i - j)) done done;
  Printf.printf "%d\n" dp.(n - 1)


module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  let dp = Array.make n None in
  let q = ref @@ IntMap.singleton 0 [0] in
  let rec dijkstra () =
    let (w, us) = IntMap.min_binding !q in
    match dp.(n - 1) with
    | Some w' when w' <= w -> w'
    | _ ->
        q := IntMap.remove w !q;
        List.iter (fun u ->
          for v = u + 1 to min (u + k) (n - 1) do
            let c = abs (hs.(u) - hs.(v)) in
            if
              match dp.(v) with
              | None -> true
              | Some w' -> w + c < w'
            then begin
              dp.(v) <- Some (w + c);
              q := IntMap.add (w + c) (v :: try IntMap.find (w + c) !q with Not_found -> []) !q
            end
          done) us;
        dijkstra () in
  Printf.printf "%d\n" @@ dijkstra ()


module WeightedDirectedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  val dijkstra :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 始点から辿り着けなければNoneを返す *)
    (Vertex.t -> Weight.t option)
end =
struct
  module WMap = Map.Make (Weight)
  module VMap = Map.Make (Vertex)

  let dijkstra e s =
    (* 始点sからの距離 *)
    (* d に入っていない頂点への距離は無限大とみなす *)
    let d = ref @@ VMap.singleton s Weight.zero in
    (* 優先度付きキュー *)
    let q = ref @@ WMap.singleton Weight.zero [s] in
    (* ダイクストラ法のメインループ *)
    let rec dijkstra_aux t =
      match WMap.min_binding !q with
      | exception Not_found ->
          (try Some (VMap.find t !d) with Not_found -> None)
      | (w, us) ->
          if
            (* 現時点で終点までの距離が分かっているか *)
            try Weight.compare (VMap.find t !d) w <= 0
            with Not_found -> false
          (* 既に終点までの距離が分かっているので返す *)
          then Some (VMap.find t !d)
          else begin
            (* 終点までの距離が分かっていないので，ダイクストラ法を続行 *)
            q := WMap.remove w !q;
            List.iter (fun u ->
              if 0 <= Weight.compare (VMap.find u !d) w then
                (* 未だ頂点uを訪れていない *)
                List.iter (fun (v, c) ->
                  let open Weight in
                  if
                    try 0 < Weight.compare (VMap.find v !d) (w + c)
                    with Not_found -> true  (* d.(v) は無限大 *)
                  then begin
                    d := VMap.add v (w + c) !d;
                    q := WMap.add (w + c) (v :: try WMap.find (w + c) !q with Not_found -> []) !q
                  end) (e u)) us;
            dijkstra_aux t
          end in dijkstra_aux
end

module Int = struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let compare = compare
end

module G = WeightedDirectedGraph (Int) (Int)

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  let Some ans = G.dijkstra (fun i ->
    Array.to_list @@ Array.init (min k (n - i - 1)) @@ fun j -> (i + j + 1, abs (hs.(i) - hs.(i + j + 1)))) 0 (n - 1) in
  Printf.printf "%d\n" ans


let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let h = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let dp = Array.make n max_int in
  dp.(0) <- 0;
  for i = 1 to n-1 do
    for j = 1 to min i k do
      dp.(i) <-
        min dp.(i) (dp.(i-j) + abs (h.(i-j) - h.(i)))
    done
  done;
  Printf.printf "%d\n" dp.(n-1)


let rec solve (ws, vs) weight k =
    match (ws, vs) with
    | (w :: ws', v :: vs') ->
        if weight >= w
        then solve (ws', vs') weight (fun r ->
             solve (ws', vs') (weight - w) (fun r' -> k @@ max r (v + r')))
        else solve (ws', vs') weight k
    | _ -> k 0

let () =
    Scanf.scanf "%d %d\n" @@ fun n w ->
        let rec loop n (ws, vs) =
            if n = 0 then (ws, vs)
            else Scanf.scanf "%d %d\n" @@ fun w v ->
                loop (n - 1) (w :: ws, v :: vs)
        in
        let ws, vs = loop n ([], []) in
        Printf.printf "%d\n" @@ solve (ws, vs) w (fun x -> x)

Score : 100 points

Problem Statement

There are N items, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.

Taro has decided to choose some of the N items and carry them home in a knapsack.
The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq W \leq 10^5

1 \leq w_i \leq W

1 \leq v_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N W
w_1 v_1
w_2 v_2
:
w_N v_N

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items 1 and 3 should be taken.
Then, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.

Sample Input 2

5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000

Sample Output 2

5000000000

The answer may not fit into a 32-bit integer type.

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items 2, 4 and 5 should be taken.
Then, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.


let rec solve (ws, vs) weight =
    match (ws, vs) with
    | (w :: ws', v :: vs') ->
        if weight >= w
        then max (solve (ws', vs') weight) (v + solve (ws', vs') (weight - w))
        else solve (ws', vs') weight
    | _ -> 0

let () =
    Scanf.scanf "%d %d\n" @@ fun n w ->
        let rec loop n (ws, vs) =
            if n = 0 then (ws, vs)
            else Scanf.scanf "%d %d\n" @@ fun w v ->
                loop (n - 1) (w :: ws, v :: vs)
        in
        let ws, vs = loop n ([], []) in
        Printf.printf "%d\n" @@ solve (ws, vs) w


let n, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let wvs = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let dp = Array.make_matrix n (w + 1) 0
let _ =
  for i = 0 to w do let (w', v) = wvs.(0) in if w' <= i then dp.(0).(i) <- v done;
  for i = 1 to n - 1 do
    for j = 0 to w do
      dp.(i).(j) <- dp.(i - 1).(j);
      let w', v = wvs.(i) in
      if w' <= j then dp.(i).(j) <- max dp.(i).(j) @@ dp.(i - 1).(j - w') + v done done;
  Printf.printf "%d\n" @@ dp.(n - 1).(w)


let () = Scanf.scanf "%d %d\n" @@ fun n wmax ->
  let wvs = Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun w v -> w, v in
  let dp = Array.make (wmax + 1) 0 in
  Array.iter (fun (w, v) ->
    for w' = wmax - w downto 0 do
      dp.(w + w') <- max dp.(w + w') (v + dp.(w'))
    done) wvs;
  Printf.printf "%d\n" @@ Array.fold_left max min_int dp


module IntMap = Map.Make (struct
  type t = int
  let compare = compare
end)

let () = Scanf.scanf "%d %d\n" @@ fun n wmax ->
  let wvs = Array.to_list @@ Array.init n @@ fun _ ->
    Scanf.scanf "%d %d\n" @@ fun w v -> w, v in
  Printf.printf "%d\n" @@
    IntMap.fold (fun _ -> max)
      (List.fold_left (fun m (w, v) ->
        IntMap.fold (fun w' v' m ->
          if wmax < w + w' then m
          else IntMap.add (w + w') (max (v + v') @@
            try IntMap.find (w + w') m with Not_found -> min_int) m) m m) (IntMap.singleton 0 0) wvs) min_int


let longer s1 s2 =
    if fst s1 >= fst s2
    then s1
    else s2

let rec update t_i s dp dp_i_j1 dp_i1_j1 =
    match s, dp with
    | s_j :: s', dp_i1_j :: dp' ->
        let dp_i_j =
            if s_j = t_i
            then (1 + fst dp_i1_j1, snd dp_i1_j1 ^ s_j)
            else longer dp_i1_j dp_i_j1
        in dp_i_j :: update t_i s' dp' dp_i_j dp_i1_j
    | _ -> dp

let rec solve s t dp =
    match t with
    | t_i :: t' -> solve s t' @@ update t_i s dp (0, "") (0, "")
    | [] -> dp

let () =
    let s = read_line () |> Str.split (Str.regexp "") in
    let t = read_line () |> Str.split (Str.regexp "") in
    let rec init n =
        if n = 0 then []
        else (0, "") :: init (n - 1)
    in
    let s_len = List.length s in
    solve s t (init s_len)
    |> (fun ls -> List.nth ls (s_len - 1))
    |> snd
    |> print_endline

Score : 100 points

Problem Statement

You are given strings s and t.
Find one longest string that is a subsequence of both s and t.

Notes

A subsequence of a string x is the string obtained by removing zero or more characters from x and concatenating the remaining characters without changing the order.

Constraints

s and t are strings consisting of lowercase English letters.

1 \leq |s|, |t| \leq 3000

Input

Input is given from Standard Input in the following format:

s
t

Output

Print one longest string that is a subsequence of both s and t.
If there are multiple such strings, any of them will be accepted.

Sample Input 1

axyb
abyxb

Sample Output 1

axb

The answer is axb or ayb; either will be accepted.

Sample Input 2

aa
xayaz

Sample Output 2

aa

Sample Input 3

a
z

Sample Output 3

The answer is (an empty string).

Sample Input 4

abracadabra
avadakedavra

Sample Output 4

aaadara


let longer s1 s2 =
    if fst s1 >= fst s2
    then s1
    else s2

let rec update t_i s dp dp_i_j1 dp_i1_j1 =
    match s, dp with
    | s_j :: s', dp_i1_j :: dp' ->
        let dp_i_j =
            if s_j = t_i
            then (1 + fst dp_i1_j1, s_j :: snd dp_i1_j1)
            else longer dp_i1_j dp_i_j1
        in dp_i_j :: update t_i s' dp' dp_i_j dp_i1_j
    | _ -> dp

let rec solve s t dp =
    match t with
    | t_i :: t' -> solve s t' @@ update t_i s dp (0, []) (0, [])
    | [] -> dp

let () =
    let s = read_line () |> Str.split (Str.regexp "") |> List.map (fun s -> s.[0]) in
    let t = read_line () |> Str.split (Str.regexp "") |> List.map (fun s -> s.[0]) in
    let rec init n =
        if n = 0 then []
        else (0, []) :: init (n - 1)
    in
    let s_len = List.length s in
    solve s t (init s_len)
    |> (fun ls -> List.nth ls (s_len - 1))
    |> snd
    |> List.rev
    |> List.iter print_char;
    print_newline ()


let longer s1 s2 =
    if List.length s1 >= List.length s2
    then s1
    else s2

let rec update t_i s dp dp_i_j1 dp_i1_j1 =
    match s, dp with
    | s_j :: s', dp_i1_j :: dp' ->
        let dp_i_j =
            if s_j = t_i
            then s_j :: dp_i1_j1
            else longer dp_i1_j dp_i_j1
        in dp_i_j :: update t_i s' dp' dp_i_j dp_i1_j
    | _ -> dp

let rec solve s t dp =
    match t with
    | t_i :: t' -> solve s t' @@ update t_i s dp [] []
    | [] -> dp

let () =
    let s = read_line () |> Str.split (Str.regexp "") |> List.map (fun s -> s.[0]) in
    let t = read_line () |> Str.split (Str.regexp "") |> List.map (fun s -> s.[0]) in
    let rec init n =
        if n = 0 then []
        else [] :: init (n - 1)
    in
    let s_len = List.length s in
    solve s t (init s_len)
    |> (fun ls -> List.nth ls (s_len - 1))
    |> List.rev
    |> List.iter print_char
    ;
    print_newline ()


let longer s1 s2 =
    if Buffer.length s1 >= Buffer.length s2
    then s1
    else s2

let rec update t_i s dp dp_i_j1 dp_i1_j1 =
    match s, dp with
    | s_j :: s', dp_i1_j :: dp' ->
        let dp_i_j = Buffer.create 8 in
        let () =
            if s_j = t_i then begin
                Buffer.add_buffer dp_i_j dp_i1_j1;
                Buffer.add_string dp_i_j s_j
            end else Buffer.add_buffer dp_i_j @@ longer dp_i1_j dp_i_j1
        in dp_i_j :: update t_i s' dp' dp_i_j dp_i1_j
    | _ -> dp

let rec solve s t dp =
    match t with
    | t_i :: t' ->
        let dp' = update t_i s dp (Buffer.create 8) (Buffer.create 8) in
        solve s t' dp'
    | [] -> dp

let () =
    let s = read_line () |> Str.split (Str.regexp "") in
    let t = read_line () |> Str.split (Str.regexp "") in
    let rec init n =
        if n = 0 then []
        else (Buffer.create 8) :: init (n - 1)
    in
    let s_len = List.length s in
    solve s t (init s_len)
    |> (fun ls -> List.nth ls (s_len - 1))
    |> Buffer.contents
    |> print_endline


let longer s1 s2 =
    if String.length s1 >= String.length s2
    then s1
    else s2

let rec update t_i s dp_i_j1 dp_i1_j1 dp =
    match s, dp with
    | s_j :: s', dp_i1_j :: dp' ->
        let dp_i_j =
            if s_j = t_i
            then dp_i1_j1 ^ s_j
            else longer dp_i1_j dp_i_j1
        in dp_i_j :: update t_i s' dp_i_j dp_i1_j dp'
    | _ -> dp

let rec solve s t dp =
    match t with
    | t_i :: t' -> solve s t' @@ update t_i s "" ""  dp
    | [] -> dp

let () =
    let s = read_line () |> Str.split (Str.regexp "") in
    let t = read_line () |> Str.split (Str.regexp "") in
    let rec init n =
        if n = 0 then []
        else "" :: init (n - 1)
    in
    let s_len = List.length s in
    solve s t (init s_len)
    |> (fun ls -> List.nth ls (s_len - 1))
    |> print_endline


let rec find c s =
    match s with
    | [] -> None
    | sc :: s' ->
        if sc = c
        then Some(s')
        else find c s'

let longer s1 s2 =
    if String.length s1 >= String.length s2
    then s1
    else s2

let rec solve s t =
    match s with
    | [] -> ""
    | sc :: s' ->
        match find sc t with
        | None -> solve s' t
        | Some(t') -> longer (solve s' t) (sc ^ solve s' t')

let () =
    let s =
        read_line () |> Str.split (Str.regexp "")
    in
    let t =
        read_line () |> Str.split (Str.regexp "")
    in
    print_endline @@ solve s t


let () =
  let s = read_line () in
  let t = read_line () in
  let lss = Array.make_matrix (String.length s + 1) (String.length t + 1) 0 in
  let css = Array.make_matrix (String.length s + 1) (String.length t + 1) [] in
  for i = 1 to String.length s do
    for j = 1 to String.length t do
      if s.[i - 1] = t.[j - 1] then begin
        lss.(i).(j) <- 1 + lss.(i - 1).(j - 1);
        css.(i).(j) <- s.[i - 1] :: css.(i - 1).(j - 1)
      end else if lss.(i).(j - 1) <= lss.(i - 1).(j) then begin
        lss.(i).(j) <- lss.(i - 1).(j);
        css.(i).(j) <- css.(i - 1).(j)
      end else begin
        lss.(i).(j) <- lss.(i).(j - 1);
        css.(i).(j) <- css.(i).(j - 1)
      end
    done
  done;
  (List.iter print_char @@ List.rev @@ css.(String.length s).(String.length t));
  print_newline ()


let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in get

let () =
  let s = read_line () in
  let t = read_line () in
  let dp = memoize (String.length s * String.length t) @@ fun dp -> function
    | (-1, _) -> (0, [])
    | (_, -1) -> (0, [])
    | (i, j) ->
        if s.[i] = t.[j] then
          let (l, cs) = dp (i - 1, j - 1) in
          (l + 1, s.[i] :: cs)
        else
          let (l, cs) = dp (i, j - 1) in
          let (l', cs') = dp (i - 1, j) in
          if l <= l' then (l', cs') else (l, cs) in
  (List.iter print_char @@ List.rev @@ snd @@ dp (String.length s - 1, String.length t - 1));
  print_newline ()


let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in get

let () =
  let s = read_line () in
  let t = read_line () in
  let dp = memoize (String.length s * String.length t) @@ fun dp -> function
    | (-1, _) -> (0, [])
    | (_, -1) -> (0, [])
    | (i, j) ->
        if s.[i] = t.[j] then
          let (l, cs) = dp (i - 1, j - 1) in
          (l + 1, s.[i] :: cs)
        else max (dp (i, j - 1)) (dp (i - 1, j)) in
  (List.iter print_char @@ List.rev @@ snd @@ dp (String.length s - 1, String.length t - 1));
  print_newline ()


open String
let () =
  Scanf.scanf " %s %s" @@ fun s t ->
  let s_len = length s in
  let t_len = length t in
  let dpl = Array.init (s_len+1) (fun _ -> Array.make (t_len+1) 0) in
  let dpp = Array.init (s_len+1) (fun _ -> Array.init (t_len+1) (fun _ -> [])) in
  for si = 0 to s_len-1 do
    for ti = 0 to t_len-1 do
      if s.[si] = t.[ti] then begin
        dpl.(si+1).(ti+1) <- dpl.(si).(ti) + 1;
        dpp.(si+1).(ti+1) <- s.[si] :: dpp.(si).(ti);
      end else
      if dpl.(si+1).(ti) > dpl.(si).(ti+1) then begin
        dpl.(si+1).(ti+1) <- dpl.(si+1).(ti);
        dpp.(si+1).(ti+1) <- dpp.(si+1).(ti);
      end else begin
        dpl.(si+1).(ti+1) <- dpl.(si).(ti+1);
        dpp.(si+1).(ti+1) <- dpp.(si).(ti+1);
      end
    done;
  done;
  dpp.(s_len).(t_len)
  |> List.rev |> List.iter print_char;
  print_newline ()


let christmas d =
  if d = 25 then "Christmas"
  else if d = 24 then "Christmas Eve"
  else if d = 23 then "Christmas Eve Eve"
  else "Christmas Eve Eve Eve"

let () = Scanf.scanf "%d" christmas |> Printf.printf "%s\n"

Score : 100 points

Problem Statement

In some other world, today is December D-th.

Write a program that prints Christmas if D = 25, Christmas Eve if D = 24, Christmas Eve Eve if D = 23 and Christmas Eve Eve Eve if D = 22.

Constraints

22 \leq D \leq 25

D is an integer.

Input

Input is given from Standard Input in the following format:

D

Output

Print the specified string (case-sensitive).

Sample Input 1

25

Sample Output 1

Christmas

Sample Input 2

22

Sample Output 2

Christmas Eve Eve Eve

Be sure to print spaces between the words.


Scanf.scanf "%d" (fun d ->
    print_endline @@ match d with
    | 25 -> "Christmas"
    | 24 -> "Christmas Eve"
    | 23 -> "Christmas Eve Eve"
    | 22 -> "Christmas Eve Eve Eve"
)


let ch v = if v = "25" then "Christmas" else v;;
let ch2 v = if v = "24" then "Christmas Eve" else v;;
let ch3 v = if v = "23" then "Christmas Eve Eve" else v;;
let ch4 v = if v = "22" then "Christmas Eve Eve Eve" else v;;

 print_string (ch4(ch3(ch2(ch(read_line ()))))); print_string "\n";;


let ch v = if v = "25" then "Christmas" else v;;
let ch2 v = if v = "24" then "Christmas Eve" else v;;
let ch3 v = if v = "23" then "Christmas Eve Eve" else v;;
let ch4 v = if v = "22" then "Christmas Eve Eve Eve" else v;;

print_string " "; print_string (ch4(ch3(ch2(ch(read_line ()))))); print_string "\n";;


open Printf
open Scanf

let solve d =
  let rec loop x s =
    if x = 25 then "Christmas" ^ s
    else loop (x + 1) (" Eve" ^ s) in
  loop d ""

let () =
  scanf "%d" solve |> printf "%s\n"


Printf.printf "Christmas%s\n" @@ match read_int () with 25 -> "" | 24 -> " Eve" | 23 -> " Eve Eve" | _ -> " Eve Eve Eve"


let f d = match d with
22 -> "Christmas Eve Eve Eve"
| 23 -> "Christmas Eve Eve"
| 24 -> "Christmas Eve"
| 25 -> "Christmas";;
let () = Scanf.scanf "%d" f
|> Printf.printf "%s\n"


Scanf.scanf " %d" @@ fun d ->
  print_endline @@ match d with
  | 25 -> "Christmas"
  | 24 -> "Christmas Eve"
  | 23 -> "Christmas Eve Eve"
  | 22 -> "Christmas Eve Eve Eve"
  | _ -> failwith "error"


open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem
let landl = Int64.logand
let lorl = Int64.logor
let lnotl = Int64.lognot
let lxorl = Int64.logxor
let lsll = Int64.shift_left
let lsrl = Int64.shift_right_logical
let long = Int64.of_int
let succl = Int64.succ
let predl = Int64.pred

let read_int _ = scanf " %d " (fun x -> x)
let read_long _ = scanf " %Ld " (fun x -> x)
let read_str _ = scanf " %s " (fun x -> x)
let read_double _ = scanf " %f " (fun x -> x)

let m = 1_000_000_007L

let rec gcd a b = if b = 0L then a else gcd b (a %% b)

let rec mod_pow a = function
  | 0L -> 1L
  | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m

let () =
  let d = read_int () in
  let c = "Christmas" in
  let e = "Eve" in
  let mes = match d with
    | 22 -> sprintf "%s %s %s %s" c e e e
    | 23 -> sprintf "%s %s %s" c e e
    | 24 -> sprintf "%s %s" c e
    | 25 -> c
    | _ -> assert false
  in
  printf "%s\n" mes


let rec f d = match d with
  | 0 -> "Christmas"
  | _ -> f (d-1) ^ " Eve"
let () =
  Scanf.scanf "%d\n" (fun d -> f (25-d)) |> print_string


let calc = function
  | 25 -> "Christmas"
  | 24 -> "Christmas Eve"
  | 23 -> "Christmas Eve Eve"
  | 22 -> "Christmas Eve Eve Eve"
  | n  -> string_of_int n

let () =
  let n = Scanf.scanf "%d" (fun n -> n) in
  calc n |> print_endline


let () = Scanf.scanf "%d" @@ function
    | 25 -> print_endline "Christmas"
    | 24 -> print_endline "Christmas Eve"
    | 23 -> print_endline "Christmas Eve Eve"
    | 22 -> print_endline "Christmas Eve Eve Eve"
    | _ -> ()


let () =
  let d = read_int () in
  print_string "Christmas";
  for i = d to 24 do
    print_string " Eve"
  done;
  print_newline ()


let () = print_endline @@
  Scanf.scanf "%d" @@ fun d ->
  if d = 25 then "Christmas"
  else if d = 24 then "Christmas Eve"
  else if d = 23 then "Christmas Eve Eve"
  else "Christmas Eve Eve Eve"


open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v))
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v)
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v)
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w)
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x)
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y)
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let d = get_i64 0 in
  print_endline @@
    if d = 25L then "Christmas"
    else if d=24L then "Christmas Eve"
    else if d=23L then "Christmas Eve Eve"
    else "Christmas Eve Eve Eve"


Scanf.scanf "%d" (fun n ->
    let xyh = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y h -> h, x, y)) in
    Array.sort compare xyh;

    let check cx cy =
        let h, x, y = xyh.(n - 1) in

        let ih = abs (cx - x) + abs (cy - y) + h in
        if Array.for_all (fun (h, x, y) -> max (ih - abs (cx - x) - abs (cy - y)) 0 = h) xyh then (
            Printf.printf "%d %d %d\n" cx cy ih;
            false
        ) else true
    in

    let rec loop_cy cy =
        let rec loop_cx cx =
            if cx > 100 then loop_cy (cy + 1) else
                if check cx cy then loop_cx (cx + 1)
        in
        loop_cx 0
    in
    loop_cy 0
)

Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.


Scanf.scanf "%d" (fun n ->
    let xyh = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y h -> h, x, y)) in
    Array.sort compare xyh;

    let check cx cy =
        let x, y, h = xyh.(n - 1) in

        let ih = abs (cx - x) + abs (cy - y) + h in
        if Array.for_all (fun (x, y, h) -> max (ih - abs (cx - x) - abs (cy - y)) 0 = h) xyh then (
            Printf.printf "%d %d %d\n" cx cy ih;
            false
        ) else true
    in

    let rec loop_cy cy =
        let rec loop_cx cx =
            if cx > 100 then loop_cy (cy + 1) else
                if check cx cy then loop_cx (cx + 1)
        in
        loop_cx 0
    in
    loop_cy 0
)


let n = Scanf.scanf " %d" (+) 0
let xyhs = Array.to_list @@ Array.init n @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let f cx cy ch x y h = max 0 @@ ch - abs (x - cx) - abs (y - cy) = h
let xyh = try Some (List.find (fun (_, _, h) -> h > 0) xyhs) with _ -> None
let g cx cy = function None -> 1 | Some (x, y, h) -> h + abs (x - cx) + abs (y - cy)
let _ = for i = 0 to 100 do for j = 0 to 100 do let ch = g j i xyh in
  if List.for_all (fun (x, y, h) -> f j i ch x y h) xyhs then (Printf.printf "%d %d %d\n" j i ch; exit 0) done done


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  let (ls1,ls2) = List.partition(fun(x1, y1, h1)->h1>0) ls in
  let (nx,ny,mx,my) = List.fold_left(fun (nx,ny,mx,my) (x1,y1,h1) ->
       (min (x1-h1) nx,min (y1-h1) ny,max(x1+h1) mx, max(y1+h1) my)
  ) (0,0,100,100) ls1 in
  for x=max 0 nx to min 100 mx do
   for y=max 0 ny to min 100 my do
     match ls1 with
     | [] -> assert false
     | [(x1,y1,h1)] -> Printf.printf "%d %d %d\n" x1 y1 h1; exit 0
     | l::ls ->
     if (List.exists (fun (x1,y1,h1)->x=x1&&y=y1) ls2) then () else
     let h = ck x y l in
     if (List.for_all (fun (x1,y1,h1) -> ck x y (x1,y1,h1) = h) ls) then (
             Printf.printf "%d %d %d\n" x y h;
             exit 0
     )
   done
  done
)


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  let (ls1,ls2) = List.partition(fun(x1, y1, h1)->h1>0) ls in
  let (nx,ny,mx,my) = List.fold_left(fun (nx,ny,mx,my) (x1,y1,h1) ->
       (min (x1-h1) nx,min (y1-h1) ny,max(x1+h1) mx, max(y1+h1) my)
  ) (0,0,100,100) ls1 in
  for x=max 0 nx to min 100 mx do
   for y=max 0 ny to min 100 my do
     match ls1 with
     | [] -> assert false
     | l::ls ->
     if (List.exists (fun (x1,y1,h1)->x=x1&&y=y1) ls2) then () else
     let h = ck x y l in
     if (List.for_all (fun (x1,y1,h1) -> ck x y (x1,y1,h1) = h) ls) then (
             Printf.printf "%d %d %d\n" x y h;
             exit 0
     )
   done
  done
)


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  let (ls1,ls2) = List.partition(fun(x1, y1, h1)->h1>0) ls in
  for x=0 to 100 do
   for y=0 to 100 do
     match ls1 with
     | [] -> assert false
     | l::ls ->
     if (List.exists (fun (x1,y1,h1)->x=x1&&y=y1) ls2) then () else
     let h = ck x y l in
     if (List.for_all (fun (x1,y1,h1) -> ck x y (x1,y1,h1) = h) ls) then (
             Printf.printf "%d %d %d\n" x y h;
             exit 0
     )
   done
  done
)


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  let ls = List.filter(fun(x1, y1, h1)->h1>0) ls in
  for x=0 to 100 do
   for y=0 to 100 do
     match ls with
     | [] -> assert false
     | l::ls ->
     let h = ck x y l in
     if (List.for_all (fun (x1,y1,h1) -> h1=0 || ck x y (x1,y1,h1) = h) ls) then (
             Printf.printf "%d %d %d\n" x y h;
             exit 0
     )
   done
  done
)


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  for x=0 to 100 do
   for y=0 to 100 do
     match ls with
     | [] -> assert false
     | l::ls ->
     let h = ck x y l in
     if (List.for_all (fun (x1,y1,h1) -> ck x y (x1,y1,h1) = h) ls) then (
             Printf.printf "%d %d %d\n" x y h;
             exit 0
     )
   done
  done
)


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  for x=0 to 100 do
   for y=0 to 100 do
     match ls with
     | [] -> assert false
     | l::ls ->
     let h = ck x y l in
     if (List.for_all (fun (x1,y1,h1) -> h1=0 || ck x y (x1,y1,h1) = h) ls) then (
             Printf.printf "%d %d %d\n" x y h;
             exit 0
     )
   done
  done
)


let ck cx cy (x1,y1,h1) = abs(cx-x1)+abs(cy-y1)+h1 in
Scanf.scanf "%d\n" (fun n->
  let rec loop i =
    if i=n then [] else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->(x1,y1,h1)) in
    m::loop (i+1)
  in
  let ls = loop 0 in
  for x=0 to 100 do
   for y=0 to 100 do
     match ls with
     | [] -> assert false
     | l::ls ->
     let h1 = ck x y l in
     if not (List.exists (fun p -> ck x y p <> h1) ls) then (
             Printf.printf "%d %d %d\n" x y h1;
             exit 0
     )
   done
  done
)


Scanf.scanf "%d\n" (fun n->
  let rec loop i (mx,my,xx,xy)=
    if i=n then (mx,my,xx,xy) else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->
            if h1<=0 then (mx,my,xx,xy) else
            (min mx (x1-h1),min my (y1-h1),max xx (x1+h1),max xy (y1+h1))
    ) in
    loop (i+1) m
  in
  let (mx,my,xx,xy) = loop 0 (0,0,0,0) in
  let x = (xx-mx)/2 in
  let y = (xy-my)/2 in
  Printf.printf "%d %d %d\n" ((xx+mx)/2) ((xy+my)/2) (max x y)

)


Scanf.scanf "%d\n" (fun n->
  let rec loop i (mx,my,xx,xy)=
    if i=n then (mx,my,xx,xy) else
    let m = Scanf.scanf "%d %d %d\n" (fun x1 y1 h1->
            (min mx (x1-h1),min my (y1-h1),max xx (x1+h1),max xy (y1+h1))
    ) in
    loop (i+1) m
  in
  let (mx,my,xx,xy) = loop 0 (0,0,0,0) in
  Printf.printf "%d %d %d\n" ((xx+mx)/2) ((xy+my)/2) ((xx-mx)/2)

)


let () = Scanf.scanf "%d" @@ fun n ->
  let xyhs = Array.init n @@ fun _ ->
    Scanf.scanf "\n%d %d %d" @@ fun x y h -> x, y, h in
  let (cx, cy, h) :: _ =
    List.concat @@ Array.to_list @@ Array.init 101 @@ fun cx ->
      List.concat @@ Array.to_list @@ Array.init 101 @@ fun cy ->
        let (l, r) = Array.fold_left (fun (l, r) -> function
          | (xi, yi, 0) -> (l, min r (abs (xi - cx) + abs (yi - cy)))
          | (xi, yi, hi) ->
              let h = hi + abs (xi - cx) + abs (yi - cy) in
              (max l h, min r h)) (1, max_int) xyhs in
        if r <> l then [] else [(cx, cy, l)] in
  Printf.printf "%d %d %d\n" cx cy h


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64
let undef = -7L

let n = get_i64 0
let a = Array.init (i32 n) (fun _ -> get_3_i64 0)
let () =
	Array.sort (fun (_,_,p) (_,_,q) -> -compare p q) a;
	rep 0L 100L (fun x ->
		rep 0L 100L (fun y ->
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				if h = undef then r + d,f
				else if max (h - d) 0L = r then h,f
				else h,false
			) (undef,true) a
			in
			if f then (
				printf "%Ld %Ld %Ld\n" x y h; exit 0
			); `Ok
		); `Ok
	)


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64
let undef = -7L

let n = get_i64 0
let a = Array.init (i32 n) (fun _ -> get_3_i64 0)
let () =
	Array.sort (fun (_,_,p) (_,_,q) -> -compare p q) a;
	rep 0L 100L (fun x ->
	rep 0L 100L (fun y ->
		let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
			let d = labs (p-x) + labs (q-y) in
			if h = undef then r + d,f
			else if h - d = r then h,f
			else h,false
		) (undef,true) a
		in
		if f then (
			printf "%Ld %Ld %Ld\n" x y h; exit 0
		); `Ok
	); `Ok)


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

let cartesian_product a b =
  let open List in
  let mk_tuple l n = map (fun x -> (n,x)) l in
   a |> map (mk_tuple b) |> fold_left append []
let r a b =
	let i,l = ref a,ref [] in while !i<=b do l:=!i::!l; i+=1L; done; !l

let n = get_i64 0
let mh,a =
	let mh = ref 0L in
	let a = Array.init (i32 n) (fun _ -> let (_,_,h) as r = get_3_i64 0 in mh := max !mh h; r)
	in !mh,a
let () =
let l = r 0L 100L in
cartesian_product l l |> List.iter (fun (x,y) ->
	rep mh (mh+200L) (fun h ->
		if Array.fold_left (fun u (p,q,r) ->
			u && max (h - labs (p-x) - labs (q-y)) 0L = r
		) true a then (
			printf "%Ld %Ld %Ld\n" x y h; exit 0
		) else `cont
	)
)


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

let n = get_i64 0
let mh,a =
	let mh = ref 0L in
	let a = Array.init (i32 n) (fun _ -> let (_,_,h) as r = get_3_i64 0 in mh := max !mh h; r)
	in !mh,a
let () =
rep 0L 100L (fun x ->
	rep 0L 100L (fun y ->
		rep mh (mh+200L) (fun h ->
			if Array.fold_left (fun u (p,q,r) ->
				u && max (h - labs (p-x) - labs (q-y)) 0L = r
			) true a then (
				printf "%Ld %Ld %Ld\n" x y h; exit 0
			) else `cont
		);`cont
	);`cont
)


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

module ISet = Set.Make(struct type t = int64 * int64 let compare = compare end)
let n = get_i64 0
let dat = Array.init (i32 n) (fun _ -> get_3_i64 0)
let ff = ref false
let xx,yy,hh = ref 0L,ref 0L,ref 0L

let cartesian_product a b =
  let open List in
  let mk_tuple l n = map (fun x -> (n,x)) l in
   a |> map (mk_tuple b) |> fold_left append []
let r a b =
	let l = ref [] in for i=a to b do l := i :: !l done;!l

let () =
	let l = r 0 100 in
	let a = cartesian_product l l |> Array.of_list in
	Array.sort (fun _ _ -> (Random.int 3) -$ 1) a;
	(* Array.iter (fun (x,y) -> printf "%d %d\n" x y) a; *)
	Array.iter (fun (x,y) ->
		let x,y = i64 x, i64 y in
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
			let d = labs (p-x) + labs (q-y) in
			let h2 = r + d in
			(* printf "  %Ld %Ld\n" h h2; *)
			if r = 0L then (
				if h - d > 0L then (
					(h,false)
				) else (h,f)
			)else if h = -1L then (
				(h2,f)
			) else if h <> h2 then (
				(h,false)
			) else (
				(h,f)
			)
		) (-1L,true) dat in
		if h > 0L && f then (
			printf "%Ld %Ld %Ld\n" x y h; exit 0;
		)
	) a


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

module ISet = Set.Make(struct type t = int64 * int64 let compare = compare end)
let n = get_i64 0
let dat = Array.init (i32 n) (fun _ -> get_3_i64 0)
let ff = ref false
let xx,yy,hh = ref 0L,ref 0L,ref 0L

let cartesian_product a b =
  let open List in
  let mk_tuple l n = map (fun x -> (n,x)) l in
   a |> map (mk_tuple b) |> fold_left append []
let r a b =
	let l = ref [] in for i=a to b do l := i :: !l done;!l

let () =
	let l = r 0 100 in
	let a = cartesian_product l l |> Array.of_list in
	Array.sort (fun _ _ -> (Random.int 3) -$ 1) a;
	Array.iter (fun (x,y) ->
		let x,y = i64 x, i64 y in
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
			let d = labs (p-x) + labs (q-y) in
			let h2 = r + d in
			(* printf "  %Ld %Ld\n" h h2; *)
			if r = 0L then (
				if h - d > 0L then (
					(h,false)
				) else (h,f)
			)else if h = -1L then (
				(h2,f)
			) else if h <> h2 then (
				(h,false)
			) else (
				(h,f)
			)
		) (-1L,true) dat in
		if h > 0L && f then (
			printf "%Ld %Ld %Ld\n" x y h; exit 0;
		)
	) a


open Printf
open Scanf

let id x = x
let pair x y = x, y

let n = scanf "%d" id
let vs = Array.init n (fun _ -> scanf " %d %d %d" (fun x y h -> x, y, h))

let () =
  for cx = 0 to 100 do
    for cy = 0 to 100 do
      let flg = ref true in
      let h = ref 0 in
      for i = 0 to n - 1 do
        let (x', y', h') = vs.(i) in
        if h' > 0 then begin
          let v = abs (x' - cx) + abs (y' - cy) + h' in
          if !h = 0 then begin
            h := v;
          end;
          if !h >= 0 && v <> !h then flg := false
        end
      done;
      if !flg && !h >= 0 then begin
        printf "%d %d %d\n" cx cy !h;
        exit 0
      end
    done
  done


open Printf
open Scanf

let id x = x
let pair x y = x, y

let n = scanf "%d" id
let vs = Array.init n (fun _ -> scanf " %d %d %d" (fun x y h -> x, y, h))

let () =
  for cx = 0 to 100 do
    for cy = 0 to 100 do
      let flg = ref true in
      let h = ref ~-1 in
      for i = 0 to n - 1 do
        let (x', y', h') = vs.(i) in
        if h' > 0 then begin
          let v = abs (x' - cx) + abs (y' - cy) + h' in
          if !h < 0 then begin
            h := v;
          end;
          if !h >= 0 && v <> !h then flg := false
        end
      done;
      if !flg && !h >= 0 then begin
        printf "%d %d %d\n" cx cy !h;
        exit 0
      end
    done
  done


open Printf
open Scanf

let id x = x
let pair x y = x, y

let n = scanf "%d" id
let vs = Array.init n (fun _ -> scanf " %d %d %d" (fun x y h -> x, y, h))

let () =
  for cx = 0 to 100 do
    for cy = 0 to 100 do
      let flg = ref true in
      let h = ref ~-1 in
      for i = 0 to n - 1 do
        let (x', y', h') = vs.(i) in
        if h' >= 0 then begin
          let v = abs (x' - cx) + abs (y' - cy) + h' in
          if !h < 0 then begin
            h := v;
          end;
          if v <> !h then flg := false
        end
      done;
      if !flg && !h >= 0 then begin
        printf "%d %d %d\n" cx cy !h;
        exit 0
      end
    done
  done


open Printf
open Scanf

let id x = x
let pair x y = x, y

let n = scanf "%d" id
let vs = Array.init n (fun _ -> scanf " %d %d %d" (fun x y h -> x, y, h))

let () =
  for cx = 0 to 100 do
    for cy = 0 to 100 do
      let flg = ref true in
      let h = ref ~-1 in
      for i = 0 to n - 1 do
        let (x', y', h') = vs.(i) in
        if h' > 0 then begin
          let v = abs (x' - cx) + abs (y' - cy) + h' in
          if !h < 0 then begin
            h := v;
          end;
          if v <> !h then flg := false
        end
      done;
      if !flg && !h >= 0 then begin
        printf "%d %d %d\n" cx cy !h;
        exit 0
      end
    done
  done


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

module ISet = Set.Make(struct type t = int64 * int64 let compare = compare end)
let n = get_i64 0
let dat = Array.init (i32 n) (fun _ -> get_3_i64 0)
let ff = ref false
let xx,yy,hh = ref 0L,ref 0L,ref 0L

(* let () =
	rep 0L 100L (fun x ->
		rep 0L 100L (fun y ->
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					if h - d > 0L then (
						(h,false)
					) else (h,f)
				)else if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if h > 0L && f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	printf "%Ld %Ld %Ld\n" !xx !yy !hh *)

	let ff = ref false
	let xx,yy,hh = ref 0L,ref 0L,ref 0L
let ng = ref @@ ISet.empty
let c = ref 0L
let rec f x0 y0 =
	c := !c + 1L;
	if !c > 101L * 101L then ()
	else
	let y0 = ref y0 in
	rep x0 100L (fun x ->
		rep !y0 100L (fun y ->
			if ISet.exists ((=) (x,y)) !ng then `Ok
			else
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					if h - d > 0L then (
						(h,false)
					) else (h,f)
				)else if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if h > 0L && f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	y0 := 0L;
	if !hh <= 0L then (
		ng := ISet.add (!xx,!yy) !ng;
		ff := false;
		f !xx !yy;
	) else ()

let () =
	f 0L 0L;
	printf "%Ld %Ld %Ld\n" !xx !yy !hh


open Printf
open Scanf

let id x = x
let pair x y = x, y

let n = scanf "%d" id
let vs = Array.init n (fun _ -> scanf " %d %d %d" (fun x y h -> x, y, h))

let () =
  for cx = 0 to 100 do
    for cy = 0 to 100 do
      let (x', y', h') = vs.(0) in
      let r = ref (abs (x' - cx) + abs (y' - cy) + h') in
      let flg = ref true in
      for i = 1 to n - 1 do
        let (x', y', h') = vs.(i) in
        let v = abs (x' - cx) + abs (y' - cy) + h' in
        if !r < 0 then begin
          r := v;
        end;
        if v > 0 && v <> !r then flg := false
      done;
      if !flg then begin
        printf "%d %d %d\n" cx cy !r;
        exit 0
      end
    done
  done


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

module ISet = Set.Make(struct type t = int64 * int64 let compare = compare end)
let n = get_i64 0
let dat = Array.init (i32 n) (fun _ -> get_3_i64 0)
let ff = ref false
let xx,yy,hh = ref 0L,ref 0L,ref 0L

(* let () =
	rep 0L 100L (fun x ->
		rep 0L 100L (fun y ->
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					if h - d > 0L then (
						(h,false)
					) else (h,f)
				)else if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if h > 0L && f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	printf "%Ld %Ld %Ld\n" !xx !yy !hh *)

	let ff = ref false
	let xx,yy,hh = ref 0L,ref 0L,ref 0L
let ng = ref @@ ISet.empty
let c = ref 0L
let rec f x0 y0 =
	c := !c + 1L;
	if !c > n * n then ()
	else
	let y0 = ref y0 in
	rep x0 100L (fun x ->
		rep !y0 100L (fun y ->
			if ISet.exists ((=) (x,y)) !ng then `Ok
			else
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					if h - d > 0L then (
						(h,false)
					) else (h,f)
				)else if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if h > 0L && f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	y0 := 0L;
	if !hh <= 0L then (
		ng := ISet.add (!xx,!yy) !ng;
		ff := false;
		f !xx !yy;
	) else ()

let () =
	f 0L 0L;
	printf "%Ld %Ld %Ld\n" !xx !yy !hh


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

let () =
	let n = get_i64 0 in
	let dat = Array.init (i32 n) (fun _ -> get_3_i64 0) in
	let ff = ref false in
	let xx,yy,hh = ref 0L,ref 0L,ref 0L in
	rep 0L 100L (fun x ->
		rep 0L 100L (fun y ->
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					if h - d > 0L then (
						(h,false)
					) else (h,f)
				)else if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if h > 0L && f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	printf "%Ld %Ld %Ld\n" !xx !yy !hh


open Printf
open Scanf

let id x = x
let pair x y = x, y

let n = scanf "%d" id
let vs = Array.init n (fun _ -> scanf " %d %d %d" (fun x y h -> x, y, h))

let () =
  for cx = 0 to 100 do
    for cy = 0 to 100 do
      let (x', y', h') = vs.(0) in
      let r = abs (x' - cx) + abs (y' - cy) + h' in
      let flg = ref true in
      for i = 1 to n - 1 do
        let (x', y', h') = vs.(i) in
        let v = abs (x' - cx) + abs (y' - cy) + h' in
        if v <> r then flg := false
      done;
      if !flg && r > 0 then begin
        printf "%d %d %d\n" cx cy r;
        exit 0
      end
    done
  done


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

let () =
	let n = get_i64 0 in
	let dat = Array.init (i32 n) (fun _ -> get_3_i64 0) in
	let ff = ref false in
	let xx,yy,hh = ref 0L,ref 0L,ref 0L in
	rep 0L 100L (fun x ->
		rep 0L 100L (fun y ->
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					if h - d > 0L then (
						(h,false)
					) else (h,f)
				)else if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	printf "%Ld %Ld %Ld\n" !xx !yy !hh

(* module ISet = Set.Make(struct type t = int64 * int64 let compare = compare end)
let n = get_i64 0
let dat = Array.init (i32 n) (fun _ -> get_3_i64 0)
let ff = ref false
let xx,yy,hh = ref 0L,ref 0L,ref 0L
let ng = ref @@ ISet.empty
let rec f x0 y0 =
	let y0 = ref y0 in
	rep x0 100L (fun x ->
		rep !y0 100L (fun y ->
			if ISet.exists ((=) (x,y)) !ng then `Ok
			else
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if h = -1L then (
					(h2,f)
				) else if r = 0L then (
					(h,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	y0 := 0L;
	if !hh <= 0L then (
		ng := ISet.add (!xx,!yy) !ng;
		ff := false;
		f !xx !yy;
	) else ()

let () =
	f 0L 0L;
	printf "%Ld %Ld %Ld\n" !xx !yy !hh
 *)


open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let abs v = abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) let min_int,max_int = min_int,max_int end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done let repb from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod (~~| !i) with | `Break -> f := false | _ -> i := !i +$ 1 done; !f let repm from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod !m (~~| !i) with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; !m let repmb from_ to_ m_init fbod = let i,f,m = ref ~|from_,ref true,ref m_init in while !i <= ~|to_ && !f do match fbod (~~| !i) !m with | `Break -> f := false | `Break_m m' -> (f := false; m := m') | `Ok m' -> (i := !i +$ 1; m := m') done; (!m,!f) let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
	let abs v = Int64.abs v let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) = let open Int64 in (logand),(logor),(logxor),lognot,(fun u v -> shift_left u (~|v)),(fun u v -> shift_right u (~|v)),(fun u v -> shift_right_logical u (~|v)) let min_int,max_int = Int64.min_int,Int64.max_int let get_string _ = scanf " %s" (fun v -> v)
	let i32,i64 = Int64.to_int,Int64.of_int let alen a = i64 @@ Array.length a
	let dump_array a = a |> Array.to_list |> string_of_list Int64.to_string |> print_endline let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y) let repi from_ to_ fbod = let i,f = ref from_,ref true in while !i <= to_ && !f do match fbod !i with | `Break -> f := false | _ -> i := !i +$ 1 done
end open MyInt64

let () =
	let n = get_i64 0 in
	let dat = Array.init (i32 n) (fun _ -> get_3_i64 0) in
	let ff = ref false in
	let xx,yy,hh = ref 0L,ref 0L,ref 0L in
	rep 0L 100L (fun x ->
		rep 0L 100L (fun y ->
			(* printf "%Ld %Ld\n" x y; *)
			let h,f = Array.fold_left (fun (h,f) (p,q,r) ->
				let d = labs (p-x) + labs (q-y) in
				let h2 = r + d in
				(* printf "  %Ld %Ld\n" h h2; *)
				if r = 0L then (
					(h,f)
				)else
				if h = -1L then (
					(h2,f)
				) else if h <> h2 then (
					(h,false)
				) else (
					(h,f)
				)
			) (-1L,true) dat in
			if f then (
				ff := true; xx := x; yy := y; hh := h; `Break
			) else `Ok
		);
		if !ff then `Break else `Ok
	);
	printf "%Ld %Ld %Ld\n" !xx !yy !hh