Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
a = c.most_common()[0][1]
b = [c.most_common()[p][0] for p in range(len(c.most_common())) if c.most_common()[p][1] == a]
b.sort()
for k in range(len(b)):
    print(b[k])


### FIXED CODE ###

import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
mx = max(c.values())
A = [e for e,j in c.items() if j == mx]
A.sort()
for p in A:
  print(p)
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())

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

def solve(N):
    for a in range(1, 3501):
        N1 = 4*a - N
        N2 = N * a
        if N1 < 0: continue
        # print("N1, N2 = ", N1, N2)
        for b in range(1, 3501):
            N3 = b * N1 - N2
            N4 = b * N2
            g = gcd(N3, N4)
            N3 //= g
            N4 //= g
            if N3 == 1:
                print(a, b, N4)
                return

# for N in range(2, 100):
#     # print("N:::", N)
#     solve(N)
    
solve(N)



### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import re
import string

N = int(input())

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

def solve(N):
    for a in range(1, 3501):
        N1 = 4*a - N
        N2 = N * a
        if N1 < 0: continue
        for b in range(1, 3501):
            N3 = b * N1 - N2
            N4 = b * N2
            if N4 > 0 and N3 > 0 and N4 % N3 == 0:
                print(a, b, N4//N3)
                return
    
solve(N)
### BUGGY CODE ###

a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections

# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num):
    if num <= 1:
        assert False
    factors = []
    divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    while len(divisors):
        d = divisors.pop(0)
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

small_factors = set(prime_factorization(small))
big_factors = set(prime_factorization(big))

print(len(small_factors.intersection(big_factors)) + 1)


### FIXED CODE ###

a, b = [int(i) for i in input().split()]
small = min(a, b)
big = max(a, b)

import sys

if small == 1:
    print(1)
    sys.exit(0)

import math
import collections

# FYI: https://ja.wikipedia.org/wiki/%E8%A9%A6%E3%81%97%E5%89%B2%E3%82%8A%E6%B3%95
def prime_factorization(num, divisors=None):
    if num <= 1:
        assert False
    factors = []

    # divisorsを使い回せるようにする。
    #   - 二度生成した場合にかかる時間が許容できない場合
    #   - エラトステネスの篩などで素数テーブルを既に持っている場合
    if not divisors:
        divisors = [2] + [i for i in range(3, int(math.sqrt(num)) + 1) if i % 2 != 0]

    for d in divisors:
        # divisorsを引数で与えた場合のみ起こりうる
        if num < d:
            break
        while num % d == 0:
            factors.append(d)
            num //= d

    if num != 1:
        factors.append(num)
    return factors

divisors = [2] + [i for i in range(3, int(math.sqrt(big)) + 1) if i % 2 != 0]
small_factors = set(prime_factorization(small, divisors))
big_factors = set(prime_factorization(big, divisors))

print(len(small_factors.intersection(big_factors)) + 1)
### BUGGY CODE ###

from collections import defaultdict
INF = 9999999999999999999999999999

def spanning_tree(G):
  n = len(G)
  T = {}
  added = set()
  min_c = INF
  for i in G:
    for j in G[i]:
      if G[i][j] < min_c:
        min_c = G[i][j]
        min_e = (i, j)
  T[min_e] = min_c
  added.add(min_e[0])
  added.add(min_e[1])
  while len(added) < n:
    min_c = INF
    for u in added:
      for v in G[u]:
        if v in added:
          continue
        if G[u][v] < min_c:
          min_c = G[u][v]
          min_e = (u, v)
    T[min_e] = min_c
    added.add(min_e[1])
  return T


G = {}

n, m = [int(v) for v in input().strip().split(' ')]
for i in range(n):
  G[i] = {}
for _ in range(m):
  s, t, c = [int(v) for v in input().strip().split(' ')]
  G[s][t] = c
  G[t][s] = c

if m == 0:
  print(0)
  exit()

T = spanning_tree(G)

s = 0
for e in T:
  s += T[e]

print(s)

### FIXED CODE ###

from collections import defaultdict
from heapq import heappush, heappop
INF = 9999999999999999999999999999

def spanning_tree(G):
  n = len(G)
  T = {}
  added = set([0])
  heap = []
  for v in G[0]:
    heappush(heap, (G[0][v], (0, v)))
  while len(added) < n:
    while True:
      c, e = heappop(heap)
      if e[1] not in added:
        break
    T[e] = c
    added.add(e[1])
    for v in G[e[1]]:
      heappush(heap, (G[e[1]][v], (e[1], v)))

  return T


G = {}

n, m = [int(v) for v in input().strip().split(' ')]
for i in range(n):
  G[i] = {}
for _ in range(m):
  s, t, c = [int(v) for v in input().strip().split(' ')]
  G[s][t] = c
  G[t][s] = c

if m == 0:
  print(0)
  exit()

T = spanning_tree(G)

s = 0
for e in T:
  s += T[e]

print(s)
### BUGGY CODE ###

# 嘘解法なおそうとおもったけどなおらん。
N, K = map(int, input().split())
A = list(map(int, input().split()))

binary = [bin(a) for a in A]
bin_K = bin(K)
ma_len = max([len(e) for e in binary] + [len(bin_K)]) - 2
B = [e[2:].zfill(ma_len) for e in binary]
bin_K = bin_K[2:].zfill(ma_len)
ans = 0
X = []


def latter(div, ma_len, B, bin_K):
    X = []
    for i in range(div, ma_len):
        num_0 = 0
        num_1 = 0
        for j in range(len(B)):
            if B[j][i] == "0":
                num_0 += 1
            else:
                num_1 += 1
        if num_1 >= num_0:
            X.append("0")
        else:
            X.append("1")
    return X


former = []
cand = [bin_K]
for i in range(ma_len):
    if bin_K[i] == "1":
        cand.append("".join(former + ["0"] + latter(i + 1, ma_len, B, bin_K)))
    former.append(bin_K[i])

# print(B)
# print(bin_K)
# print(cand)

if K != 0:
    print(max([sum([int(e, 2) ^ int(b, 2) for b in B]) for e in cand]))
else:
    print(sum([0 ^ int(b, 2) for b in B]))


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

binary = [bin(a) for a in A]
bin_K = bin(K)
ma_len = max([len(e) for e in binary] + [len(bin_K)]) - 2
B = [e[2:].zfill(ma_len) for e in binary]
bin_K = bin_K[2:].zfill(ma_len)
ans = 0
X = []

flag = False
for i in range(ma_len):
    num_1 = 0
    num_0 = 0
    for j in range(N):
        if B[j][i] == "0":
            num_0 += 1
        else:
            num_1 += 1
    if num_1 >= num_0:
        added = "0"
        if bin_K[i] == "1":
            flag = True
    else:
        if flag:
            added = "1"
        else:
            if bin_K[i] == "1":
                added = "1"
            else:
                added = "0"
    if added == "1":
        ans += 2**(ma_len - i - 1) * num_0
    else:
        ans += 2**(ma_len - i - 1) * num_1
    # X.append(added)

print(ans)
# print("".join(X))
### BUGGY CODE ###

import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    S = [0] + list(map(int, input().split()))
    T = [0] + list(map(int, input().split()))

    dp = [[0] * (M+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, M+1):
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + int(S[i] == T[j]) * (dp[i-1][j-1] + 1)) % MOD

    return (dp[N][M] + 1) % MOD


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, M = map(int, input().split())
    S = [0] + list(map(int, input().split()))
    T = [0] + list(map(int, input().split()))

    dp = [[0] * (M+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, M+1):
            if S[i] == T[j]:
                dp[i][j] = dp[i-1][j] + dp[i][j-1] + 1
            else:
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
            dp[i][j] %= MOD

    return (dp[N][M] + 1) % MOD


if __name__ == '__main__':
    print(main())
### BUGGY CODE ###

S = input()
modulo = 10 ** 9 + 7

remainder = {0: 1}

for s in S:
    rx = {r: 0 for r in range(13)}
    for n in (range(10) if s == '?' else [int(s)]):
        for r in remainder:
            r2 = (r * 10 + n) % 13
            rx[r2] += remainder[r]
            rx[r2]  = rx[r2] % modulo
    remainder = rx

print(remainder[5] % modulo)


### FIXED CODE ###

S = input()
modulo = 10 ** 9 + 7

remainder = {0: 1}

for s in S:
    rx = {r: 0 for r in range(13)}
    for n in (range(10) if s == '?' else [int(s)]):
        for r in remainder:
            r2 = (r * 10 + n) % 13
            rx[r2] += remainder[r]
            rx[r2]  = rx[r2] % modulo
    remainder = rx

print(remainder[5] % modulo)
### BUGGY CODE ###

import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    k, s = read_int_list()
    res = 0
    for x in range(0, k + 1):
        for y in range(0, k + 1):
            for z in range(0, k + 1):
                if s == x + y + z:
                    res += 1
    print(res)


main()


### FIXED CODE ###

import sys

# sys.stdin = open('b1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    k, s = read_int_list()
    res = 0
    for x in range(0, k + 1):
        for y in range(0, k + 1):
            z = s - (x + y)
            if 0 <= z <= k:
                res += 1
    print(res)


main()
### BUGGY CODE ###

H,W = map(int,input().split())
Ch, Cw = map(int,input().split())
Dh, Dw = map(int,input().split())
S = [list(input()) for _ in range(H)]

INF = H * W

# def steppable(h,w):
#     if not (h in range(H)) or not (w in range(W)):
#         return False
#     if S[h][w] == '#':
#         return False
#     else:
#         return True

num_step = [[INF for w in range(W)] for h in range(H)]
num_step[Ch - 1][Cw - 1] = 0

# スタート地点を定義
queue = [(Ch - 1, Cw - 1)]
num_warp = 0

# 幅優先探索
while not queue == []:
    magic_tiles = []
    while not queue == []:
        h = queue.pop(0) # here 
        if h[0] == Dh - 1 and h[1] == Dw - 1:
            print(num_warp)
            exit()
        next_  = [
            (h[0] + 1, h[1], 0),
            (h[0] - 1, h[1], 0),
            (h[0], h[1] + 1, 0),
            (h[0], h[1] - 1, 0),]

        for n in next_:
            if 0 <= n[0] < H and 0 <= n[1] < W and S[n[0]][n[1]] == '.' and num_step[n[0]][n[1]] > num_warp:
                queue.append(n)
                num_step[n[0]][n[1]] = num_warp

        # 魔法を使っていける場所を検討
        dx = [-2, -1 , 0, 1, 2]
        dy = [-2, -1 , 0, 1, 2]

        for x in dx:
            for y in dy:
                 if 0 <= h[0] + y < H and 0 <= h[1] + x < W and S[h[0] + y][h[1] + x] == '.' \
                     and num_step[h[0] + y][h[1] + x] == INF:
                    magic_tiles.append((h[0] + y, h[1] + x))

    num_warp += 1

    # キューの追加
    for magic in magic_tiles:
        if num_step[magic[0]][magic[1]] == INF:
            num_step[magic[0]][magic[1]] == num_warp
            queue.append((magic[0],magic[1]))

print(-1)

### FIXED CODE ###

H,W = map(int,input().split())
Ch, Cw = map(int,input().split())
Dh, Dw = map(int,input().split())
S = [list(input()) for _ in range(H)]

INF = H * W

dx = [1, 0, -1, 0]
dy = [0, -1, 0, 1]

num_step = [[INF for w in range(W)] for h in range(H)]
num_step[Ch - 1][Cw - 1] = 0

# スタート地点を定義
queue = [(Ch - 1, Cw - 1)]
num_warp = 0

# 幅優先探索
while not queue == []:
    magic_tiles = []
    while not queue == []:
        h = queue.pop() # here 
        if h[0] == Dh - 1 and h[1] == Dw - 1:
            print(num_warp)
            exit()
        for i in range(4):
            if 0 <= h[0]+dy[i] < H and 0 <= h[1]+dx[i] < W and S[h[0]+dy[i]][h[1]+dx[i]] == '.' \
                 and num_step[h[0]+dy[i]][h[1]+dx[i]] > num_warp:
                queue.append((h[0]+dy[i], h[1]+dx[i]))
                num_step[h[0]+dy[i]][h[1]+dx[i]] = num_warp

        # 魔法を使っていける場所を検討
        mx = [-2, -1 , 0, 1, 2]
        my = [-2, -1 , 0, 1, 2]

        for x in mx:
            for y in my:
                 if 0 <= h[0] + y < H and 0 <= h[1] + x < W and S[h[0] + y][h[1] + x] == '.' \
                     and num_step[h[0] + y][h[1] + x] == INF:
                    magic_tiles.append((h[0] + y, h[1] + x))

    num_warp += 1

    # キューの追加
    for magic in magic_tiles:
        if num_step[magic[0]][magic[1]] == INF:
            num_step[magic[0]][magic[1]] = num_warp
            queue.append((magic[0], magic[1]))

print(-1)
### BUGGY CODE ###

h,w=map(int,input().split())
M=[input() for _ in range(h)]

def f(x,y):
    c=1
    for i in range(1,h):
        if x+i>=h:
            break
        if M[x+i][y]=='#':
            break
        c+=1
    for i in range(-1,-h,-1):
        if x+i<0:
            break
        if M[x+i][y]=='#':
            break
        c+=1
        
    for i in range(1,w):
        if y+i>=w:
            break
        if M[x][y+i]=='#': 
            break
        c+=1
    for i in range(-1,-w,-1):
        if y+i<0:
            break
        if M[x][y+i]=='#':
            break
        c+=1
    return c
            
        

ans=1

for i in range(h):
    for j in range(w):
        if M[i][j]=='#':
            continue
        ans=max(ans,f(i,j))
print(ans)
        

### FIXED CODE ###

h,w=map(int,input().split())
M=[input() for _ in range(h)]

L=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if M[i][j]=='#':
            L[i][j]=0
        elif j!=0:
            L[i][j]=L[i][j-1]+1
        else:
            L[i][j]=1
    
R=[[0]*w for _ in range(h)]
for i in range(h):
    for j in reversed(range(w)):
        if M[i][j]=='#':
            R[i][j]=0
        elif j!=w-1:
            R[i][j]=R[i][j+1]+1
        else:
            R[i][j]=1

U=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if M[i][j]=='#':
            U[i][j]=0
        elif i!=0:
            U[i][j]=U[i-1][j]+1
        else:
            U[i][j]=1

D=[[0]*w for _ in range(h)]
for i in reversed(range(h)):
    for j in range(w):
        if M[i][j]=='#':
            D[i][j]=0
        elif i!=h-1:
            D[i][j]=D[i+1][j]+1
        else:
            D[i][j]=1

ans=1
for i in range(h):
    for j in range(w):
        if M[i][j]=='#':
            continue
        ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)
### BUGGY CODE ###

def main():
    n,q = map(int, input().split())
    tl = []
    que = []
    d = dict()
    for _ in range(n):
        s,t,x = map(int, input().split())
        tl.append((s-x,1,x))
        tl.append((t-x,0,x))
    for _ in range(q):
        t = int(input())
        que.append(t)
        tl.append((t,2))
    tl.sort()
    wor = dict()
    wcur = 0
    cur = -1
    flg = 0
    for x in tl:
        if x[1] == 1:
            wcur += 1
            wor[x[2]] = 1
            if cur < 0 or x[2] < cur:
                cur = x[2]
                flg = 0
        elif x[1] == 0:
            wcur -= 1 
            wor[x[2]] = 0
            if x[2] == cur:
                flg = 1
            if not wcur:
                cur = -1
                flg = 0
        else:
            if flg:
                cur = min([x for x in wor if wor[x]])
                flg = 0
            d[x[0]] = cur
    for i in que:
        print(d[i])

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n,q = map(int, input().split())
    tl = []
    que = []
    d = dict()
    for _ in range(n):
        s,t,x = map(int, input().split())
        tl.append((s-x,1,x))
        tl.append((t-x,0,x))
    for _ in range(q):
        t = int(input())
        tl.append((t,2))
    tl.sort()
    wor = set()
    wcur = 0
    cur = -1
    flg = 0
    for x in tl:
        if x[1] == 1:
            wcur += 1
            wor.add(x[2])
            if cur < 0 or x[2] < cur:
                cur = x[2]
                flg = 0
        elif x[1] == 0:
            wcur -= 1 
            wor.remove(x[2])
            if x[2] == cur:
                flg = 1
            if not wcur:
                cur = -1
                flg = 0
        else:
            if flg:
                cur = min(wor)
                flg = 0
            print(cur)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N, P = map(int, input().split())
S = input()

if P == 2 or P == 5:
    ans = 0
    for i, s in enumerate(S):
        if int(s) % P == 0:
            ans += i+1
    print(ans)
    import sys
    sys.exit()

val = int(S)
order = 10 ** N
suf_nums = [-1] * N
s = -1
for i in range(N):
    if s != -1:
        val -= s * order
    suf_nums[i] = val
    s = int(S[i])
    order //= 10

surpluses = [0] * P
ans = 0
for num in suf_nums.__reversed__():
    surplus = num % P
    surpluses[surplus] += 1
    if surplus == 0:
        ans += surpluses[0]
    else:
        ans += surpluses[surplus] - 1

print(ans)



### FIXED CODE ###

N, P = map(int, input().split())
S = input()

if P == 2 or P == 5:
    ans = 0
    for i, s in enumerate(S):
        if int(s) % P == 0:
            ans += i+1
    print(ans)
    import sys
    sys.exit(0)

surpluses = [0] * P
s = 0
power = 1
for i in range(N):
    s = (s + int(S[-1-i]) * power) % P
    surpluses[s % P] += 1
    power = (power * 10) % P

ans = surpluses[0]
for count in surpluses:
    ans += count * (count - 1) // 2

print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
p=1
for i in a[:k]:
    p*=i
for i,j in zip(a[k:],a):
    q=p*i/j
    if q>p: print("Yes")
    else: print("No")
    p=q


### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k,len(a)):
    if a[i]>a[i-k]: print("Yes")
    else: print("No")
### BUGGY CODE ###

S = input()
n = len(S)
a = [int(S)]
cnt = 0

for i in range(n):
    a.append(a[i] - int(S[i])*(10**(n-i-1)))

a = list(map(lambda x: x%2019, a))

for i in range(2019):
    tmp = a.count(i)
    cnt += tmp*(tmp-1)//2

print(cnt)


### FIXED CODE ###

import sys

input = sys.stdin.readline

S = input().rstrip()
n = len(S)
l = [0]*2019
d = 10

t = int(S[n-1])
l[t%2019] += 1

l[0] += 1

for i in range(n-2, -1, -1):
    t += int(S[i])*d%2019
    l[t%2019] += 1 
    d *= 10
    d %= 2019

ans = 0

for i in l:
    ans += i*(i-1)//2

print(ans)
### BUGGY CODE ###

n = int(input())
m = list(map(int, input().split()))
count = []
for i in range(1, n+1):
  if i not in m:
    break
  
  for j in range(len(m)):
    if i==m[j]:
      count += [i]
      m = m[j+1:]
      break
if len(count) == 0:
  print(-1)
else:
  print(n-len(count))

### FIXED CODE ###

class Stack:
  def __init__(self):
    self.count = 1
    self.lst = []
  
  def push(self, element):
    if element == self.count:
      self.lst.append(element)
      self.count += 1
  
  def length(self):
    return len(self.lst)

n = int(input())
a = list(map(int, input().split()))
stack = Stack()
for i in a:
  stack.push(i)

b = stack.length()
if b == 0:
  print('-1')
else:
  print(n - b)
### BUGGY CODE ###

def main():
    n = int(input())
    s = input()
    r_list, g_list, b_list = [], [], []

    for i, c in enumerate(s):
        if c == "R":
            r_list.append(i)
        elif c == "G":
            g_list.append(i)
        elif c == "B":
            b_list.append(i)

    cnt = 0
    for r in r_list:
        for g in g_list:
            for b in b_list:
                if r < g < b and g - r != b - g:
                    cnt += 1
                elif r < b < g and b - r != g - b:
                    cnt += 1
                elif g < r < b and r - g != b - r:
                    cnt += 1
                elif g < b < r and b - g != r - b:
                    cnt += 1
                elif b < r < g and r - b != g - r:
                    cnt += 1
                elif b < g < r and g - b != r - g:
                    cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    s = input()
    r_set, g_set, b_set = set(), set(), set()

    for i, c in enumerate(s):
        if c == "R":
            r_set.add(i)
        elif c == "G":
            g_set.add(i)
        elif c == "B":
            b_set.add(i)

    cnt = 0
    for i in range(n):
        for j in range(i + 1, n):
            k = 2 * j - i

            if i in r_set and j in g_set and k in b_set:
                cnt += 1
            elif i in r_set and j in b_set and k in g_set:
                cnt += 1
            elif i in g_set and j in r_set and k in b_set:
                cnt += 1
            elif i in g_set and j in b_set and k in r_set:
                cnt += 1
            elif i in b_set and j in r_set and k in g_set:
                cnt += 1
            elif i in b_set and j in g_set and k in r_set:
                cnt += 1

    print(len(r_set) * len(g_set) * len(b_set) - cnt)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

N = int(input())
v = [[] for _ in range(N)]
for i in range(N - 1) :
    a = int(input())
    v[a-1].append(i + 1)

def rec(cur) :
    ret = sorted([rec(nex) for nex in v[cur]], reverse=True)
    if len(ret) == 0 :
        return 0
    return max([i + 1 + ret[i] for i in range(len(ret))])
    
print(rec(0))

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
v = [[] for _ in range(N)]
for i in range(N - 1) :
    a = int(input())
    v[a-1].append(i + 1)

l = [0]
i = 0
while i < len(l) :
    cur = l[i]
    for nex in v[cur] :
        l.append(nex)
    i += 1

dp = [0] * N
while len(l) > 0 :
    cur = l.pop()
    ret = []
    for nex in v[cur] :
        ret.append(dp[nex])
    
    if len(ret) == 0 :
        continue
        
    ret.sort(reverse=True)
    dp[cur] = max([i + 1 + ret[i] for i in range(len(ret))])
    
print(dp[0])
### BUGGY CODE ###

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 height(cx,x,cy,y,h):
    return(max(0,h-abs(cx-x)-abs(cy-y)))
def judge(cx,cy,hc):
    for i in range(N):
        hcand = height(cx,x[i],cy,y[i],hc) 
        if hcand < h[i]:
            return(-1)
        if hcand > h[i]:
            return(1)
    return(0)
        
    
for cx in range(cm+1):
    for cy in range(cm+1):
        left = -1
        right = 1000000001
        while right > left:
            mid = (right+left)//2
            j = judge(cx,cy,mid) 
            if j == 0:
                print(cx,cy,mid)
                exit()
            elif j == 1:
                right = mid
            else:
                left = mid

### FIXED CODE ###

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()