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):
n = int(input())

x = []
y = []
h = []
u = 0
for i in range(n):
    a = list(map(int, input().split(' ')))
    x.append(a[0])
    y.append(a[1])
    h.append(a[2])
    if h[i] > 0:
        u = i

for cx in range(101):
    for cy in range(101):
        H = abs(cx - x[u]) + abs(cy - y[u]) + h[u]
        ok = True
        for i in range(n):
            ok &= max(H - abs(cx - x[i]) - abs(cy - y[i]), 0) == h[i]
        if ok:
            print(cx, cy, H)

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))
for cx in range(101):
    for cy in range(101):
        flag = 1
        H = None
        maxh = 10**10
        for x, y, h in xyh:
            if h == 0:
                maxh = min(maxh, abs(x - cx) + abs(y - cy))
            else:
                if H is None:
                    H = h + abs(x - cx) + abs(y - cy)
                    if H > maxh:
                        flag = 0
                        break
                else:
                    if H != h + abs(x - cx) + abs(y - cy):
                        flag = 0
                        break
        if flag and H <= maxh:
            print(cx, cy, H)
            sys.exit()

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
x = [];y=[];h=[]
sh = -1
for i in range(n):
    xa,ya,ha = readInts()
    x.append(xa);y.append(ya);h.append(ha);
    if ha > 0:
        sh = i

resx = -1;resy =-1;resh=-1;
for Cx in range(101):
    for Cy in range(101):
        ok = True
        H = h[sh] + abs(x[sh] - Cx) + abs(y[sh] - Cy)
        
        for i in range(n):
            if h[i] == 0:
                if H > abs(x[i] - Cx) + abs(y[i] - Cy):
                    ok = False
                    break
            elif h[i] > 0:
                if H -h[i] !=  abs(x[i] - Cx) + abs(y[i] - Cy):
                    ok = False
                    break
        if ok:
            resx = Cx;resy = Cy;resh = H;

print(resx,resy,resh)

Solution (Python):
N = int(input())
XYH = [tuple(map(int,input().split())) for i in range(N)]

cands = []
for cx in range(101):
    for cy in range(101):
        ch = None
        for x,y,h in XYH:
            if h==0: continue
            d = abs(cx-x) + abs(cy-y)
            if ch is None:
                ch = h + d
            else:
                if h + d != ch:
                    break
        else:
            cands.append((cx,cy,ch))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        d = abs(cx-x) + abs(cy-y)
        if h != max(ch - d, 0):
            break
    else:
        print(cx,cy,ch)
        exit()

Solution (Python):
def check(X,Y):
    Hs = []
    for x,y,h in xyh:
        if h > 0:
            H = h + abs(x-X) + abs(y-Y)
            Hs.append(H)
        else:
            H = Hs[0]
            if abs(x-X) + abs(y-Y) < H:
                return False
    
    if len(set(Hs)) == 1:
        print(X,Y,Hs[0])
        return True
    else:
        return False

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda a:a[2],reverse=True)

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

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda t: t[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = xyh[0]
        H = h0+abs(x0-cx)+abs(y0-cy)
        flag = True
        
        for x, y, h in xyh:
            h2 = max(H-abs(x-cx)-abs(y-cy), 0)
            
            if h!=h2:
                flag = False
                
        if flag:
            print(cx, cy, H)
            exit()

Solution (Python):
N = int(input())
P = [list(map(int,input().split())) for k in range(N)]

for h in range(P[0][2],P[0][2]+201):
    for x in range(101):
        for y in range(101):
            f = 1
            for e in P:
                if e[2] != max(0,h-abs(e[0]-x)-abs(e[1]-y)):
                    f = 0
                    break
            if f == 1:
                print(x,y,h)
                exit(0)

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

HXY.sort(reverse=True)

for i in range(101):
    for j in range(101):
        H = -1
        for k in range(n):
            h, x, y = HXY[k]
            if h > 0:
                temp = h + abs(x-i) + abs(y-j)
                if H > 0:
                    if H != temp:
                        break
                else:
                    H = temp
            else:
                if H - abs(x-i) - abs(y-j) > 0:
                    break
        else:
            if H > 0:
                print(i, j, H)

Solution (Python):
N = int(input())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[2],reverse=True)
for x in range(101):
    for y in range(101):
        a,b,h = A[0]
        H = h+abs(x-a)+abs(y-b)
        flag = 1
        for i in range(1,N):
            a,b,h = A[i]
            if max(0,H-abs(x-a)-abs(y-b))==h:continue
            else:
                flag = 0
                break
        if flag==1:
            cx = x
            cy = y
            break
    if flag==1:break
print(cx,cy,H)

Solution (Python):
n = int(input())
lst = []
for i in range(n):
    xi, yi, hi = map(int, input().split())
    lst.append([xi, yi, hi])

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

for cx in range(101):
    for cy in range(101):
        h = -1
        for i in range(n):
            xi, yi, hi = lst[i]
            if h == -1:
                h = hi + abs(xi-cx) + abs(yi-cy)
                continue
            if hi != max(h - abs(xi-cx) - abs(yi-cy), 0):
                h = -1
                break
        if h != -1:
            print(cx, cy, h)
            exit()

Solution (Python):
N = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(N)]
bx, by, bh = [xyh for xyh in XYH if xyh[2] > 0][0]

def solve(cx, cy):
    H = abs(cx - bx) + abs(cy - by) + bh

    for x, y, h in XYH:
        D = max(0, H - abs(cx - x) - abs(cy - y))
        if D != h:
            return 0
    return H

for x in range(101):
    for y in range(101):
        h = solve(x, y)
        if h > 0:
            print(x, y, h)
            exit()

print(-1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
xyh = [LIST() for _ in range(N)]

for x, y, h in xyh:
	if h >= 1:
		tmp = (x, y, h)

for i in range(101):
	for j in range(101):
		x_, y_, h_ = tmp
		H = h_ + abs(i-x_) + abs(j-y_)

		for x, y, h in xyh:
			if max(H-abs(x-i)-abs(y-j), 0) != h:
				break
		else:
			print(i, j, H)
			exit()

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

for cx in range(101):
    for cy in range(101):
        h = kouho[0][2] + abs(kouho[0][0]-cx) + abs(kouho[0][1]-cy)
        flag = False
        for i in range(1,n):
            now = max(h - abs(kouho[i][0]-cx) - abs(kouho[i][1]-cy),0)
            if now != kouho[i][2]:
                flag = True
                break
        if not flag:
            print(str(cx) + " " + str(cy) + " " + str(h))
            exit()

Solution (Python):
N = int(input())
XYH = []
for i in range(N):
    XYH.append(list(map(int,input().split())))

flag=0
for Cx in range(101):
    for Cy in range(101):
        Hcands = []
        for i in range(N):
            X = XYH[i][0]
            Y = XYH[i][1]
            h = XYH[i][2]
            if h>0:
                Hcand = abs(Cx-X)+abs(Cy-Y)+h
                break
        for i in range(N):
            X = XYH[i][0]
            Y = XYH[i][1]
            h = XYH[i][2]
            if h != max(Hcand-abs(Cx-X)-abs(Cy-Y), 0):
                flag=0
                break
            else:
                flag=1
        if flag==1:
            print(Cx,Cy,Hcand)
            break
    if flag==1:
        break

Solution (Python):
n = int(input())
info = [list(map(int, input().split())) for _ in range(n)]
for i in info:
    if i[2] > 0:
        x, y, h = i[0], i[1], i[2]
        break
for i in range(101):
    for j in range(101):
        H = h + abs(x - i) + abs(y - j)
        if all(max(H - abs(k[0] - i) - abs(k[1] - j), 0) == k[2] for k in info):
            print(i, j, H)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
xyh = [LIST() for _ in range(N)]
ins = (-1, -1, -1)

for x, y, h in xyh:
	if h >= 1:
		ins = (x, y, h)

x1, y1, h1 = ins   

for Cx in range(101):
	for Cy in range(101):
		H = h1 + abs(x1-Cx) + abs(y1-Cy)  
		for x, y, h in xyh:
			if max(H-abs(x-Cx)-abs(y-Cy), 0) != h:
				break
		else:
			print(Cx, Cy, H)
			exit()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
xyh = [LIST() for _ in range(N)]
xyh.sort(key = lambda x:[x[0], x[1]])

for Cx in range(101):
	for Cy in range(101):
		H = 0
		H_max = INF
		for x, y, h in xyh:
			if h == 0:
				H_max = min(H_max, h + abs(x-Cx) + abs(y-Cy))
			else:
				if H == 0:
					H = h + abs(x-Cx) + abs(y-Cy)
				else:
					if H != h + abs(x-Cx) + abs(y-Cy):
						break
		else:
			if H <= H_max:
				print(Cx, Cy, H)
				break
	else:
		continue
	break

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
xyh = [LIST() for _ in range(N)]

h_dict = defaultdict(int)
xyh.sort(key = lambda x:[x[0], x[1]])

for Cx in range(101):
	for Cy in range(101):
		H = 0
		H_max = INF
		for x, y, h in xyh:
			if h == 0:
				H_max = min(H_max, h + abs(x-Cx) + abs(y-Cy))
			else:
				if H == 0:
					H = h + abs(x-Cx) + abs(y-Cy)
				else:
					if H != h + abs(x-Cx) + abs(y-Cy):
						break

		else:
			if H <= H_max:
				print(Cx, Cy, H)
				break
	else:
		continue
	break

Solution (Python):
n = int(input())
xyh = []
for _ in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
for cx in range(101):
    for cy in range(101):
        H = None
        maxH = 10**12
        for x, y, h in xyh:
            if h>0:
                if H is None:
                    H = h+abs(x-cx)+abs(y-cy)
                elif H!=h+abs(x-cx)+abs(y-cy):
                    break
                if H>maxH:
                    break
            else:
                maxH = min(maxH, abs(x-cx)+abs(y-cy))
                if H is not None and H>maxH:
                    break
        else:
            print(cx, cy, H)
            exit()

Solution (Python):

import sys
input = sys.stdin.readline









N = int(input())
XYH = [tuple(map(int,input().split())) for _ in range(N)]



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


for xi in range(101):
    for yi in range(101):
        flg = True
        x,y,h = XYH[0]
        
        hh0 = abs(xi-x) + abs(yi-y) + h
        for i in range(1,N):
            x,y,h = XYH[i]
            if h == 0:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 > hhi:
                    flg = False
                    break
            else:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 != hhi:
                    flg = False
                    break
        if flg:
            print(xi,yi,hh0)
            sys.exit()

Solution (Python):
n = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        H = set()
        for x, y, h in XYH:
            if h == 0:
                continue
            H.add(h + abs(x - cx) + abs(y - cy))
        if len(H) != 1:
            continue
        H = list(H)[0]
        flag = True
        for x, y, h in XYH:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print(cx, cy, H)

Solution (Python):
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
XYH.sort(key=lambda x:x[2])
X, Y, H = XYH[-1]
for cx in range(101):
    for cy in range(101):
        h = H + abs(cx-X) + abs(cy-Y)
        flag = False
        for xyh in XYH:
            if xyh[2] != max(h-abs(cx-xyh[0])-abs(cy-xyh[1]), 0):
                flag = True
        if flag: continue
        print(cx, cy, h)

Solution (Python):
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
XYH.sort(key=lambda x:x[2])
X, Y, H = XYH[-1]
for cx in range(101):
    for cy in range(101):
        h = H + abs(cx-X) + abs(cy-Y)
        flag = False
        for xyh in XYH:
            if xyh[2] != max(h-abs(cx-xyh[0])-abs(cy-xyh[1]), 0):
                flag = True
        if flag: continue
        print(cx, cy, h)
        exit()

Solution (Python):
N = int(input())
xyh = []
si = 0
for i in range(N):
    x, y, h = map(int, input().split())
    xyh.append([x,y,h])
    if h > 0:
        si = i

for cx in range(101):
    for cy in range(101):
        H = xyh[si][2] + abs(cx - xyh[si][0]) + abs(cy - xyh[si][1])
        ok = True
        for x,y,h in xyh:
            if h > 0 and H - h != abs(cx - x) + abs(cy - y):
                ok = False
            if h == 0 and H > abs(cx - x) + abs(cy - y):
                ok = False
        if ok:
            print(cx, cy, H)
            exit()

Solution (Python):
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh = sorted(xyh, key=lambda x:x[2])
ans = []
for i in range(101):
    for j in range(101):
        pre = xyh[-1][2] + abs(i-xyh[-1][0]) + abs(j-xyh[-1][1])
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            print(i, j, pre)
            exit()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    info0 = []
    info1 = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h == 0: info0.append((x, y))
        if h != 0: info1.append((x, y, h))

    for cx in range(101):
        for cy in range(101):
            H = -1
            for x, y, h in info1:
                wrong = False
                if h > 0 and H == -1:
                    H = h + abs(cx - x) + abs(cy - y)
                elif h > 0:
                    if H != h + abs(cx - x) + abs(cy - y):
                        wrong = True
                        break
            if wrong: continue
            for x, y in info0:
                wrong = False
                if abs(cx - x) + abs(cy - y) < H:
                    wrong = True
                    break
            if wrong: continue
            print("{} {} {}".format(cx, cy, H))
            exit()

if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
ans=[[None]*101 for _ in range(101)] 
a=[[0]*3 for _ in range(n)] 

for i in range(n):
    a[i][0],a[i][1],a[i][2]=map(int,input().split())
a=sorted(a,key=lambda x: x[2],reverse=True)

for i in range(n):
    for cx in range(101):
        for cy in range(101):
            height=a[i][2]+abs(a[i][0]-cx)+abs(a[i][1]-cy)
            if a[i][2]>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(a[i][0]-cx)+abs(a[i][1]-cy):
                        ans[cx][cy]=-1
                else:
                    ans[a[i][0]][a[i][1]]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]==None: 
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()

data = []
for i in range(N):
  x,y,h = IL()
  data.append((x,y,h))

data = sorted(data, lambda x:x[2])

import itertools
x,y,h = data.pop()
dic = {(i,j):h+(abs(i-x)+abs(j-y))  for i,j in itertools.product(range(101),repeat=2)}

while len(dic)>1:
  x,y,h = data.pop()
  for i,j in itertools.product(range(101),repeat=2):
    if (i,j) in dic:
      if h > 0:
        if dic[(i,j)] != h+(abs(i-x)+abs(j-y)):
          dic.pop((i,j))
      else:
        if dic[(i,j)] > h+(abs(i-x)+abs(j-y)):
          dic.pop((i,j))

ans = [k for k in dic][0]

print(ans[0],ans[1],dic[ans])

Solution (Python):
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda f:f[2])
p=xyh[-1]
for cx in range(0,101):
  for cy in range(0,101):
    h=p[2]+abs(p[0]-cx)+abs(p[1]-cy)
    for u in xyh:
      if u[2]!=max(0,h-abs(u[0]-cx)-abs(u[1]-cy)):
        break
    else:
      print(cx,cy,h)

Solution (Python):
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
for x in xyh:
    if x[2] > 0:
        base = x
        break
for i in range(101):
    for j in range(101):
        h = base[2] + abs(i-base[0]) + abs(j-base[1])
        for x in xyh:
            if x[2] != max(h-abs(i-x[0])-abs(j-x[1]),0):
                break
        else:
            print(i,j,h)
            exit()

Solution (Python):
def resolve():
    n=int(input())
    xyh=[[0]*3 for _ in range(n)]
    for i in range(n):
        x,y,h=map(int,input().split())
        xyh[i][0],xyh[i][1],xyh[i][2]=h,x,y
    xyh.sort(reverse=True)
    ans,flg=0,0
    for cx in range(101):
        for cy in range(101):        
            ans,flg=0,0
            for h,x,y in xyh:
                if ans==0:
                    if h==0:
                        continue
                    else:
                        ans=h+abs(x-cx)+abs(y-cy)
                else:
                    if h==0:
                        if ans>abs(x-cx)+abs(y-cy):
                            flg=1
                            break
                        else:
                            continue
                    else:
                        if ans==h+abs(x-cx)+abs(y-cy):
                            continue
                        else:
                            flg=1
                            break
            if flg==0:
                break
        if flg==0:
            break
    print(cx,cy,ans)            

if __name__ == '__main__':
    resolve()

Solution (Python):


N = int(input())
XYH = [tuple(int(i) for i in input().split()) for _ in range(N)]

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

for cx in range(101):
    for cy in range(101):
        (x, y, h) = XYH[0]
        tmp_H = h + abs(x - cx) + abs(y - cy)
        for (x, y, h) in XYH:
            if h != max(tmp_H - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            ans = (cx, cy, tmp_H)
            break

print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
XYH = [list(map(int, input().split())) for _ in range(N)]
XYH.sort(key=lambda x:x[2], reverse=True)
isOk = False
cx = 0
while cx <= 100:
  cy = 0
  while cy <= 100:
    x, y, h = XYH[0]
    H = h+abs(x-cx)+abs(y-cy)
    i = 1
    isOk = True
    while i < N and isOk:
      x, y, h = XYH[i]
      if max(H-abs(x-cx)-abs(y-cy),0) != h:
        isOk = False
      i += 1
    if isOk:
      break
    cy += 1
  if isOk:
    break
  cx += 1
print(cx, cy, H)

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

infos = []
first_info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0 and len(first_info) == 0:
        first_info = [x, y, h]
    else:
        infos.append([x, y, h])



x1, y1, h1 = first_info
for cx in range(101):
    for cy in range(101):
        isValid = True
        H = h1 + abs(x1-cx) + abs(y1-cy)
        for x2, y2, h2 in infos:
            if h2 != max(H - abs(x2-cx) - abs(y2-cy), 0):
                isValid = False

        if isValid:
            ans = [cx, cy]

cx, cy = ans
H = h1 + abs(x1-cx) + abs(y1-cy)
print(cx, cy, H)

Solution (Python):
def main():
    points = int(input())
    info = []
    for _ in range(points):
        info.append(list(map(int, input().split())))
    info.sort(key=lambda x: x[2], reverse=True)
    is_answered = False
    for x in range(101):
        if is_answered:
            break
        for y in range(101):
            now_height = abs(x - info[0][0]) + abs(y - info[0][1]) + info[0][2]
            if all(info[i][2] == max(now_height - abs(x - info[i][0]) - abs(y - info[i][1]), 0) for i in range(1, points)):
                if now_height > 0:
                    print(x, y, now_height)
                    is_answered = True
                    break


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
info = [list(map(int, input().split())) for _ in range(n)]
for Cx in range(101):
    for Cy in range(101):
        flag = False
        check = []
        for x, y, h in info:
            if h == 0:
                continue
            check.append(h+abs(x-Cx)+abs(y-Cy))
        if len(set(check)) == 1:
            flag = True
            ans_h = check[0]
            for x, y, h in info:
                if h != max(ans_h-abs(x-Cx)-abs(y-Cy), 0):
                    flag = False
        if flag:
            print(Cx, Cy, ans_h)
            exit()

Solution (Python):



def main():
    N = int(input())
    x = [None] * N
    y = [None] * N
    h = [None] * N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    
    for i in range(101):
        for j in range(101):
            flag = True
            maxH = 10**12
            H = set()
            for k in range(N):
                if h[k] == 0:
                    maxH = min(maxH, abs(x[k]-i) + abs(y[k]-j))
                else:
                    tmpH = h[k] + abs(x[k]-i) + abs(y[k]-j)
                    H.add(tmpH)
                    if len(H) > 1:
                        flag = False
                        break
            if flag and list(H)[0] <= maxH:
                print(i,j,list(H)[0])

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
x_y_h_list = []
for i in range(n):
  x_y_h_list.append(list(map(int,input().split())))
x_y_h_list.sort(key=lambda x: x[2],reverse = True)
result = []
for x in range(101):
  for y in range(101):
    H = -1
    check = True
    for x_y_h in x_y_h_list:     
      if H == -1:
        H = x_y_h[2] + abs(x_y_h[0] - x) + abs(x_y_h[1] - y)
      else:
        if x_y_h[2] != 0:
          if H != x_y_h[2] + abs(x_y_h[0] - x) + abs(x_y_h[1] - y):
            check = False
            break
        else:
          if H > abs(x_y_h[0] - x) + abs(x_y_h[1] - y):
            check = False
            break
    if check == True:
      print(x,y,H)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])
info.sort(reverse = True,key = lambda info:info[2])

ans = []
for i in range(101):
    for j in range(101):
        height = -1
        flag = True
        for k in range(N):
            minusx = abs(i - info[k][0])
            minusy = abs(j - info[k][1])
            if height == -1:
                
                height = info[k][2] + minusx + minusy
            else:
                
                if info[k][2] != max(height - minusx - minusy, 0):
                    flag = False
                    break
        if flag:
            ans = [i, j, height]
print(*ans)