Problem:
 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 .

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
n = ni()
xyh = []
for _ in range(n):
    xyh.append(tuple(list(li())))

def search_cent(xyh:list):    
    xmax ,ymax, hmax = -1, -1, -1
    for x,y,h in xyh:
        if h > hmax:
            xmax = x
            ymax = y
            hmax = h
            
    for x_cent in range(101):
        for y_cent in range(101):
            h_cent = hmax + abs(xmax-x_cent) + abs(ymax-y_cent)
            
            
            is_cent = True
            for x,y,h in xyh:
                hi = max(0, h_cent - abs(x-x_cent) - abs(y-y_cent))
                
                if hi != h:
                    is_cent = False
                    break

            if is_cent:
                return x_cent, y_cent, h_cent
        
xc, yc, hc = search_cent(xyh)
print(xc,yc,hc)

Solution (Python):
N = int(input())
x = list(0 for i in range(N))
y = list(0 for i in range(N))
h = list(0 for i in range(N))
for i in range(N):
    x[i],y[i],h[i] = (int(i) for i in input().split())


for cx in range(101): 
    for cy in range(101):
        H = -1
        for i in range(N):
            if h[i] > 0:
                tmp = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
                if H == -1:
                    H = tmp
                elif H != tmp:
                    H = -2
                    break
        if H == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i]-cx)+abs(y[i]-cy)
                if H > dist:
                    H = -2
                    break
        if H == -2:
            continue
        print(cx,cy,H)

Solution (Python):
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(x - Cx) + abs(y - Cy) + h
            break
    for x, y, h in cords:
        tmp = manhattan_distance(Cx, Cy, H, x, y)
        if h != tmp:
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()

Solution (Python):
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(x - Cx) + abs(y - Cy) + h
            break
    for x, y, h in cords:
        tmp = manhattan_distance(Cx, Cy, H, x, y)
        if (h > 0 and h != tmp) or (h == 0 and h < tmp):
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()

Solution (Python):
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n + 1):
            if j == n:
                break
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                break
        if j == n:
            break
print("{} {} {}".format(cx, cy, H[0]))

Solution (Python):
MAX = 101

def judge_center(Cx, Cy, cords):
    H = -1
    for x, y, h in cords:
        if h > 0:
            tmpH = abs(x - Cx) + abs(y - Cy) + h
            if H == -1:
                H = tmpH
            else:
                if tmpH != H:
                    return -1
    for x, y, h in cords:
        if h == 0:
            tmpH = abs(x - Cx) + abs(y - Cy) + h
            if H > tmpH:
                return -1
    return H

def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(MAX):
        for tmp_Cy in range(MAX):
            H = judge_center(tmp_Cx, tmp_Cy, cords)
            if H != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, H))
                return 0


if __name__ == '__main__':
    main()

Solution (Python):


N = int(input())
xN, yN, hN = [0] * N, [0] * N, [0] * N
for i in range(N):
    xN[i], yN[i], hN[i] = map(int, input().split())


for y in range(101):
    for x in range(101):
        
        tmpH = 0
        
        cnt1, cnt2 = 0, 0
        
        for i in range(N):
            
            if hN[i] == 0:
                continue
            cnt1 += 1
            
            h = hN[i] + abs(x - xN[i]) + abs(y - yN[i])
            
            if tmpH == 0:
                tmpH = h
                cnt2 += 1
            
            else:
                
                if tmpH != h:
                    break
                else:
                    cnt2 += 1
        
        
        for i in range(N):
            if hN[i] == 0:
                cnt1 += 1
                
                
                if tmpH > abs(x - xN[i]) + abs(y - yN[i]):
                    break
                else:
                    cnt2 += 1
        
        if cnt1 == cnt2:
            print(str(x) + ' ' + str(y) + ' ' + str(tmpH))
            exit()

Solution (Python):
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for t in range(n):
    if h[t] >= 1:
        break
for cx, cy in itertools.product(range(101), range(101)):
    H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
    if H < 1:
        continue
    for i in range(n + 1):
        if i == n:
            break
        if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
            break
    if i == n:
        break
print("{} {} {}".format(cx, cy, H))

Solution (Python):
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            Cx, Cy, h = tuple(Xs[0])
            H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))

Solution (Python):
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            Cx, Cy, h = tuple(Xs[0])
            H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))

Solution (Python):
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            for i in range(len(Xs)):
                h = max(H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]), 0)
                if h != Xs[i][2]:
                    break
                if i == len(Xs)-1:
                    print("%d %d %d" % (x, y, H))
                    exit(0)


solv(Xs)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    ex,ey,eh = map(int,input().split())
    if eh != 0:
        l.append([ex,ey,eh])

def func2(cx,cy,l):
    ans = l[2] + abs(l[0]-cx) +  abs(l[1]-cy)
    return ans

if len(l) == 1:
    print(l[0][0], l[0][1], l[0][2])
    exit()

for i in range(101):
    for j in range(101):
        for k in range(len(l)-1):
            if func2(i,j,l[k]) == func2(i,j,l[k+1]):
                if k == len(l)-2:
                    print(i, j, func2(i,j,l[k]))
                    exit()
            else:
                break

Solution (Python):
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2],reverse=True)
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if j[2]==0:
            if k>l:
                n-=1
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Solution (Python):
n = int(input())
ss = [[int(i) for i in input().split()] for i in range(n)]

ss = sorted(ss, key=lambda x: x[2], reverse=True)


cx, cy, ch = ss[0]
if len(ss) == 1:
    print(cx, cy, ch)
else:
    for a in range(101):
        for b in range(101):
            H = ch + abs(cx-a) + abs(cy - b)
            for x, y, h in ss[1:]:
                if h != max(H - abs(x-a) - abs(y - b), 0):
                    break
            else:
                print(a, b, H)
                flg = True

Solution (Python):
n = int(input())
card = []

for i in range(n):
    x,y,h = [int(i) for i in input().split()]
    card.append([x,y,h])


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H
            H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))

Solution (Python):
import sys
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

max_h = P[0][2]

for hh in range(max_h+200, max_h-1, -1):
    for cx in range(101):
        for cy in range(101):
            for x, y, h in P:
                th = max(hh-abs(cx-x)-abs(cy-y),0)
                if h == th:
                    continue
                else:
                    break
            else:
                print('%d %d %d' % (cx, cy, hh))
                sys.exit(0)

Solution (Python):
import sys
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

max_h = P[0][2]

for hh in range(max_h+200, max_h-1, -1):
    for cx in range(101):
        for cy in range(101):
            for x, y, h in P:
                th = max(hh-abs(cx-x)-abs(cy-y),0)
                if h == th:
                    continue
                else:
                    break
            else:
                print('%d %d %d' % (cx, cy, hh))
                sys.exit(0)

Solution (Python):
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
h=0
for a in range(n):
    if e[a][2]>0:
        s=a
        break
for x in range(0,101):
    for y in range(0,101):
            k=abs(x-e[s][0])+abs(y-e[s][1])+e[s][2]
            for i in range(0,n):
                if e[i][2]!=max(k-abs(x-e[i][0])-abs(y-e[i][1]),0):
                    break
            else:
                print(x,y,k)

Solution (Python):
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
h_max = max(h for x, y, h in points)

for H in range(h_max, h_max + 1000):
    for Cx in range(101):
        for Cy in range(101):
            ok = True
            for x, y, h in points:
                h_calc = max(H - abs(x - Cx) - abs(y - Cy), 0)
                if h != h_calc:
                    ok = False
                    break
            if ok:
                print('{} {} {}'.format(Cx, Cy, H))
                exit()

Solution (Python):
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
maxz = xyz[0][2]
maxy = xyz[0][1]
maxx = xyz[0][0]
for k in range(N):
    if xyz[k][2] > maxz:
        maxz = xyz[k][2]
        maxx = xyz[k][0]
        maxy = xyz[k][1]
for i in range(101):
    for j in range(101):
        H = maxz + abs(maxx-i) + abs(maxy-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        else:
            if H != 0:
                flag = True
                print("{} {} {}".format(i, j, H))
                break
    if flag:
        break

Solution (Python):

import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
narr = np.array(arr)
x_min  = narr[:,0].min()
x_max = narr[:,0].max()
y_min = narr[:,1].min()
y_max =  narr[:,1].max()
mx = narr[:,2].max()
for k in range(mx+100,mx-1,-1):
    for i in range(x_min,x_max+1):
        for j in range(y_min,y_max+1):
            for x,y,h in arr:
                h_ = max(k-abs(i-x)-abs(j-y),0)
                if h_ != h:
                    break
            else:
                print (i,j,k)
                exit()

Solution (Python):
def inpl():
    return list(map(int, input().split()))

import numpy as np

N = int(input())
X = np.zeros(N, dtype=np.int64)
Y = np.zeros(N, dtype=np.int64)
H = np.zeros(N, dtype=np.int64)


Q = sorted([inpl() for _ in range(N)], key=lambda x: x[2], reverse=True)

for i, q in enumerate(Q):
    X[i], Y[i], H[i] = q

for cx in range(101):
    for cy in range(101):
        cH = H[0] + np.abs(X[0] - cx) + np.abs(Y[0] - cy)
        if np.all(H == np.maximum(cH - np.abs(X - cx) - np.abs(Y - cy), 0)):
            print(cx, cy, cH)

Solution (Python):
n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = data[0][0], data[0][1], data[0][2]
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        for i in range(1, n):
            xi, yi, hi = data[i][0], data[i][1], data[i][2]
            if hi == 0 and h < abs(xi - cx) + abs(yi - cy):
                continue
            if h != hi + abs(xi - cx) + abs(yi - cy):
                break
        else:
            print(cx, cy, h)
            exit()

Solution (Python):
import sys
N = input()
x = []
y = []
h = []
for i in range(N):
	_x, _y, _h = map(int, raw_input().split())
	x.append(_x)
	y.append(_y)
	h.append(_h)

for _x in range(101):
	for _y in range(101):
		candH = -1
		for i in range(N):
			if h[i] > 0:
				tmp = h[i] + abs(x[i] - _x) + abs(y[i] - _y)
				if candH == -1:
					candH = tmp
				elif candH == tmp:
					continue
				else:
					candH = -2
					break
		if candH == -2:
			continue
		for i in range(N):
			if h[i] == 0:
				dist = abs(x[i] - _x) + abs(y[i] - _y)
				if dist < candH:
					candH = -2
					break
					
		if candH == -2:
			continue
		print _x, _y, candH
		sys.exit()

Solution (Python):
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h != max(_H - abs(cx - x) - abs(cy - y), 0):
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Solution (Python):
N = int(input())

points = [None] * N
for i in range(0, N):
    points[i] = list(map(int, input().split()))

h_max = max([h for x, y, h in points])

for H in range(h_max + 100, h_max - 1, -1):
    for Cx in range(101):
        for Cy in range(101):
            ok = True
            for X, Y, h1 in points:
                h2 = max(H - abs(X - Cx) - abs(Y - Cy), 0)
                if h1 != h2:
                    ok = False
                    break
            if ok:
                print('{} {} {}'.format(Cx, Cy, H))
                exit()

Solution (Python):

import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    info_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, h] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        info_list.append((h, x, y))

    info_list.sort(reverse = True)
    for Cx in range(101):
        for Cy in range(101):
            pre_H = -1
            is_all_eq = True
            for info in info_list:
                x = info[1]
                y = info[2]
                h = info[0]
                if h == 0:
                    if pre_H - abs(Cx - x) - abs(Cy - y) > 0:
                        is_all_eq = False
                        break
                else:
                    H =  h + abs(Cx - x) + abs(Cy - y)

                    if pre_H == -1 or H == pre_H:
                        pre_H = H
                    else:
                        is_all_eq = False
                        break;
            if is_all_eq == True:
                break
        if is_all_eq == True:
                break

    print Cx, Cy, H

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]

def get_cands(x, y, h):
    for xc in range(100 + 1):
        for yc in range(100 + 1):
            hc = h + abs(xc - x) + abs(yc - y)
            yield (xc, yc, hc)

def is_valid(top, view):
    xt, yt, ht = top
    xv, yv, hv = view
    return hv == max(0, ht - abs(xt - xv) - abs(yt - yv))

cand = set(get_cands(*next(filter(lambda x: x[2] > 0, XYH))))
ans = filter(lambda x: all(is_valid(x, v) for v in XYH), cand)

print(*next(ans))

Solution (Python):
import sys


n = int(input())
l = [[int(i) for i in input().split()] for j in range(n)]


for i in range(0, 101):
    for j in range(0, 101):
        ans = 1
        for k in range(n):
            if l[k][2] != 0:
                h = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
                break
        for k in range(n):
            if l[k][2] != max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0):
                ans = 0
        if ans:
            print(i, j, h)
            sys.exit()

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for w in range(n):
   if l[w][2]>0:
     k=w
     break
for x in range(101):
  for y in range(101):
    a=l[k][2]+abs(l[k][0]-x)+abs(l[k][1]-y)
    c=0
    for z in range(n):
      if max((a-abs(l[z][0]-x)-abs(l[z][1]-y)),0)==l[z][2]:c+=1
      if c==n:
        print(x,y,a)

Solution (Python):
def c_pyramid(N, Pos):
    from itertools import product
    
    for cx, cy in product(range(101), repeat=2):
        
        for x, y, h in Pos:
            if h > 0:
                height = h + abs(cx - x) + abs(cy - y)
        
        for x, y, h in Pos:
            if h != max((height - abs(cx - x) - abs(cy - y)), 0):
                break
        else:
            ans = [cx, cy, height]
            break
    ans = '{0} {1} {2}'.format(*ans)
    return ans

N = int(input())
Pos = [[int(i) for i in input().split()] for j in range(N)]
print(c_pyramid(N, Pos))

Solution (Python):
import numpy as np

N = int(input())
a = [list(map(int,input().split())) for i in range(N)]

for j in range(101):
    for k in range(101):
        needH = -1
        for i in range(N):
            if a[i][2] > 0:
                temp = a[i][2] + np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
                if needH == -1:
                    needH = temp
                else:
                    if needH != temp:
                        needH = -2
                        break
        if needH == -2:
            continue
            
        for i in range(N):
            if a[i][2] == 0:
                dist = np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
                if needH > dist:
                    needH = -2
                    break
        if needH == -2:
            continue
            
        print("{} {} {}\n".format(j, k, needH))

Solution (Python):
n = int(input())




xyh = []
for i in range(n):
    px, py, h = list(map(int, input().split()))
    d = {
        'px': px,
        'py': py,
        'h': h
    }
    xyh.append(d)


t = {}
for d in xyh:
    if d['h'] >= 1:
        t = d
        break


for cx in range(101):
    for cy in range(101):
        
        max_h = (
            abs(t['px'] - cx) + abs(t['py'] - cy) + t['h']
        )
        
        is_ok = True
        for d in xyh:
            if d['h'] != max(
                max_h - abs(d['px'] - cx) - abs(d['py'] - cy), 0
            ):
                is_ok = False
                break
        if is_ok:
            print(cx, cy, max_h)

Solution (Python):
def solve(C):
    C.sort(key=lambda x: x[2], reverse=True)
    for xi in range(0, 101):
        for yi in range(0, 101):
            h = C[0][2] + abs(xi - C[0][0]) + abs(yi - C[0][1])
            if all(max(h - abs(xi - c[0]) - abs(yi - c[1]), 0) == c[2] for c in C):
                return [str(xi), str(yi), str(h)]


if __name__ == "__main__":
    N = int(input())
    C = []
    for n in range(N):
        d = input().split(" ")
        C.append((int(d[0]), int(d[1]), int(d[2])))
    print(" ".join(solve(C)))

Solution (Python):
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
inlist=[]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    inlist.append([xi,yi,hi])
inlist.sort(key=lambda x :-x[2])
for i in range(n):
    xi,yi,hi=inlist[i]
    if hi==0:
        xymap[xi][yi]=-2
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]<=a:
                    pass
                else:
                    xymap[x][y]=-2
    else:
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])

Solution (Python):
n = int(input())
xyhs = [tuple(map(int,input().split())) for _ in range(n)]

idx = 0
while(xyhs[idx][2] == 0):
    idx+=1

for i in range(101):
    for j in range(101):
        nowh = xyhs[idx][2] + abs(i-xyhs[idx][0]) +abs(j-xyhs[idx][1])
        isCorrect = True
        for k in range(n):
            calch = max(nowh - abs(i-xyhs[k][0]) - abs(j-xyhs[k][1]),0)
            if calch != xyhs[k][2]:
                isCorrect = False
        
        if isCorrect:
            print(i,j,nowh)

Solution (Python):
N = int(input())
Q = [0]*N
H=0
for j in range(N):
    Q[j] = [ int(i) for i in input().split()]

for x in range(101):
    for y in range(101):
        h_kouho = {-1}
        for i in range(N):
            if  Q[i][2] != 0:
                H1 = Q[i][2] + abs(Q[i][0]- x) + abs(Q[i][1] - y)
                if h_kouho =={-1}:
                    h_kouho = {H1}
                else:
                    h_kouho = h_kouho & {H1}
            else:
                continue
        if h_kouho != set() :
            u = 0
            for i in range(N):
                if Q[i][2] != max({0,max(h_kouho)- abs(Q[i][0]- x) - abs(Q[i][1] - y)}):
                    u = 1
            if u == 0:
                print(x,y,max(h_kouho))
                break
                break
            else:
                continue
        else:
            continue

Solution (Python):
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 10000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
            else:
                if H == -1:
                    H = Hi
                else:
                    if H!=Hi:
                        contra = True
                        break
            if H > Hm:
                contra = True
                break
        if contra == False:
            print(cx,cy,H)                
            exit()

Solution (Python):
N = int(input())

X = []
Y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())

    if c > 0:
        p = i
    X.append(a)
    Y.append(b)
    h.append(c)

for Cx in range(101):
    for Cy in range(101):
        works = True
        H = h[p] + abs(X[p] - Cx) + abs(Y[p] - Cy)
        for i in range(N):
            if h[i] != max(H - abs(X[i] - Cx) - abs(Y[i] - Cy), 0):
                works = False
                break
        
        if works:
            print(Cx,Cy,H)
            quit()

Solution (Python):
N=int(input())
L=100
x=[0 for i in range(N)]
y=[0 for i in range(N)]
h=[0 for i in range(N)]
p=(-1,-1,-1)
for i in range(N):
    x[i],y[i],h[i]=map(int,input().split())
for i in range(N):
    if h[i]!=0:
        p=(x[i],y[i],h[i])
        break
if p[2]==-1:
    print("Baka")
    exit()
for Cx in range(L+1):
    for Cy in range(L+1):
        H=p[2]+abs(Cx-p[0])+abs(Cy-p[1])
        flag=1
        for i in range(N):
            hd=max([H-abs(x[i]-Cx)-abs(y[i]-Cy),0])
            if h[i]!=hd:
                flag=0
                break
        if flag==1:
            print(Cx,Cy,H)
            exit()

Solution (Python):
n = int(input())

xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))


for i in range(n):
    if xyh[i][2] != 0:
        x_ex, y_ex, h_ex = xyh[i]
        break

for cx in range(101): 
    for cy in range(101): 
        h = abs(x_ex - cx) + abs(y_ex - cy) + h_ex 

        
        flag = 0
        for i in range(n):
            x_i, y_i, h_i = xyh[i]
            if h_i == max(h - abs(x_i - cx) - abs(y_i - cy), 0):
                flag += 1
            else:
                break

        if flag == n:
            print(cx, cy, h)
            exit()

Solution (Python):
N=int(input())

data=[]

for _ in range(N):
    x,y,h=map(int,input().split())
    data.append([x,y,h])
 
def test():
    for cx in range(101):
        for cy in range(101):
            
            for i in range(N):
                if data[i][2]:
                    temph=data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
                    flag=True
                    break
            
            for d in data:
                if d[2] != max(temph-abs(d[0]-cx)-abs(d[1]-cy),0):
                    flag=False
                    break
                
            if flag:
                print(cx,cy,temph)
                return
            
test()

Solution (Python):
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        for r in xyh:
            if r[2] > 0:
                ch = r[2] + abs(r[0] - cx) + abs(r[1] - cy)
                break
        j = False
        for r in xyh:
            if r[2] != max((ch - abs(r[0] - cx) - abs(r[1] - cy)),0):
                j = True
                break
        if not j:
            print(cx,cy,ch)

Solution (Python):
from sys import exit
n=int(input())
z=[]
for i in range(n):
	x,y,h=map(int,input().split())
	z.append((x,y,h))
for i in range(101):
	for j in range(101):
		pp=-1
		ff=True
		for k in range(n):
			if(pp==-1 and z[k][2]>0):
				pp=z[k][2]+abs(z[k][0]-i)+abs(z[k][1]-j)
			else:
				zk=max(pp-abs(z[k][0]-i)-abs(z[k][1]-j),0)
				if(zk!=z[k][2]):
					ff=False
					break
		if(ff):
			for k in range(n):
				zk=max(pp-abs(z[k][0]-i)-abs(z[k][1]-j),0)
				if(zk!=z[k][2]):
					ff=False
					break
			if(ff):
				print(i,j,pp)
				exit(0)