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

n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
print(ans if ans <= 10 ** 18 else -1)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

from itertools import permutations
n,m,r=map(int,input().split())
R=list(map(int,input().split()))
l=[[float('inf')]*n for _ in range(n)]
for _ in range(m):
    a,b,c,=map(int,input().split())
    a-=1
    b-=1
    l[a][b]=c
    l[b][a]=c
for i in range(n):
    l[i][i] = 0 #自身のところに行くコストは０
def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j]=min(d[i][j],d[i][k]+d[k][j])
                
    return d
F=warshall_floyd(l)
ans=float('inf')
for v in permutations(R):
    temp=0
    for i in range(r-1):
        temp+=F[v[i]-1][v[i+1]-1]
    ans=min(ans,temp)
print(int(ans))

### FIXED CODE ###

from itertools import permutations as p
 
from scipy.sparse.csgraph import floyd_warshall
 
n, m, r = map(int, input().split())
R = list(map(int, input().split()))
l = [[0]*n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    l[a][b] = c
    l[b][a] = c
F = floyd_warshall(l)
 
ans = float("inf")
for v in p(R):
    temp = 0
    for i in range(r-1):
        temp += F[v[i]-1][v[i+1]-1]
    ans = min(ans, temp)
print(int(ans))
### BUGGY CODE ###

k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while 1:
    now += 1
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break


### FIXED CODE ###

k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while 1:
    now += 1
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break
    else:
      ok[x] = 1
### BUGGY CODE ###

import sys


def solve(N: int, S: "List[str]"):

    kuji = []

    for s in S:

        if s not in kuji:
            kuji.append(s)

    print(len(kuji))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys


def solve(N: int, S: "List[str]"):

    S = set(S)

    print(len(S))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

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

import sys

import numpy as np

input = sys.stdin.readline


def main():
    H, N = map(int, input().split())
    A = np.zeros(N, dtype=np.int32)
    B = np.zeros(N, dtype=np.int32)
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    dp = np.full(H + max(A), 10**8, dtype=np.int32)
    dp[0] = 0
    for h in range(H):
        for a, b in zip(A, B):
            if dp[h]+b < dp[h+a]:
                dp[h+a] = dp[h]+b
    ans = min(dp[H:])
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline

INF = float("inf")


def main():
    H, N = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    dp = [INF] * (H + max(A))
    dp[0] = 0
    for h in range(H):
        for a, b in zip(A, B):
            if dp[h]+b < dp[h+a]:
                dp[h+a] = dp[h]+b
    ans = min(dp[H:])
    print(ans)


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

import collections as c

h,w,m = map(int,input().split())
x = []
y = []
z = []
ans = 0
for i in range(m):
    s,t = map(int,input().split())
    x.append(s)
    y.append(t)
    z.append(tuple([s,t]))
a = c.Counter(x)
b = c.Counter(y)

for p,q in a.items():
    for r,s in b.items():
        if tuple([p,r]) in z:
            ans = max(ans,q+s-1)
        else:
            ans = max(ans,q+s)
print(ans)

### FIXED CODE ###

import collections as c

h,w,m = map(int,input().split())
x = []
y = []
z = set([])
for i in range(m):
    s,t = map(int,input().split())
    x.append(s)
    y.append(t)
    z.add(tuple([s,t]))
a = c.Counter(x)
b = c.Counter(y)
a = a.most_common()
b = b.most_common()
c = []
d = []
e = a[0][1]
f = b[0][1]

for sa in a:
    if sa[1] == e:
        c.append(sa[0])
    else:
        break
for sb in b:
    if sb[1] == f:
        d.append(sb[0])
    else:
        break

fl = 0
ans = e+f-1
for s in c:
    for t in d:
        if tuple([s,t]) not in z:
            fl = 1
            ans += 1
            break
    if fl == 1:
        break
    
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
a = []
b = []
for i in range(m):
    a_, b_ = map(int, input().split())
    if a_ == 1 or a_ == n or b_ == 1 or b_ == n:
        a.append(a_)
        b.append(b_)

for i in range(len(a)):
    if a[i] == 1 or b[i] == 1:
        x = max(a[i], b[i])
        for j in range(len(a)):
            if a[j] == x or b[j] == x:
                if max(a[j], b[j]) == n:
                    print("POSSIBLE")
                    exit()
print("IMPOSSIBLE")


### FIXED CODE ###

n, m = map(int, input().split())
a = []
b = []
for i in range(m):
    a_, b_ = map(int, input().split())
    if a_ == 1 or a_ == n or b_ == 1 or b_ == n:
        a.append(a_)
        b.append(b_)

x_min=[]
x_max=[]
for i in range(len(a)):
    if a[i] == 1 or b[i] == 1:
        x_max.append(max(a[i], b[i]))
    if a[i] == n or b[i] == n:
        x_min.append(min(a[i], b[i]))
x = x_min + x_max
if len(x) == len(set(x)):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
### BUGGY CODE ###

#動的計画法
#B 問題 - Frog 2
n, k = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("INF")]*(n)
dp[0] = 0
for i in range(1,n):
    kouho= []
    for j in range(min(k,i)+1):
        kouho.append(dp[i-j]+abs(h[i]-h[i-j]))
    dp[i] = min(kouho)
    
print(dp[n-1])

### FIXED CODE ###

#https://qiita.com/drken/items/dc53c683d6de8aeacf5a(DP問題集)
#https://atcoder.jp/contests/dp/tasks/dp_b
#ボトムアップ的
N, K = list(map(int,input().split()))
h = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N,1):
    dp[i] = min([dp[i-j] + abs(h[i] - h[i-j]) for j in range(1,min(i+1,K+1))])

print(dp[N-1])
### BUGGY CODE ###

# coding : UTF-8
N,M = map(int,input().split())

PM_list = [ input() for _ in range(M) ]
PM_list = [ list(map(int,_.split(" "))) for _ in PM_list]
PM_dict = {}

for i in PM_list:
    if i[0] in PM_dict:
        PM_dict[i[0]].append(i[1])
    else:
        PM_dict[i[0]] = [i[1]]

for j in PM_dict:
    PM_dict[j].sort()

for k in PM_list:
    print("{}{}".format(str(k[0]).zfill(6),str(PM_dict[k[0]].index(k[1])+1).zfill(6)))

### FIXED CODE ###

# coding : UTF-8
import bisect
N,M = map(int,input().split())

PM_list = [ input() for _ in range(M) ]
PM_list = [ list(map(int,_.split(" "))) for _ in PM_list]
PM_dict = {}

for i in PM_list:
    if i[0] in PM_dict:
        PM_dict[i[0]].append(i[1])
    else:
        PM_dict[i[0]] = [i[1]]

for j in PM_dict:
    PM_dict[j].sort()

for k in PM_list:
    print("{}{}".format(str(k[0]).zfill(6),str(bisect.bisect_left(PM_dict[k[0]],k[1])+1).zfill(6)))
### BUGGY CODE ###

MOD = 1000000007

S = input()
memo = [[0] * 13 for i in range(len(S)+1)]

memo[0][0] = 1
for idx in range(len(S)):
	ch = S[idx]
	if(ch == '?'):
		for num in range(10):
			mod = ((10**(len(S) - idx - 1)) * num)%13
			for i in range(13):
				if(memo[idx][i] > 0):
					memo[idx+1][(i+mod)%13] += memo[idx][i] 
					memo[idx+1][(i+mod)%13] %= MOD
	else:
		num = int(ch)
		mod = ((10**(len(S) - idx - 1)) * num)%13
		for i in range(13):
			if(memo[idx][i] > 0):
				memo[idx+1][(i+mod)%13] += memo[idx][i] 
				memo[idx+1][(i+mod)%13] %= MOD

print(memo[len(S)][5]%MOD)

### FIXED CODE ###

MOD = 1000000007
S = input()
memo = [[0] * 13 for i in range(len(S)+1)]
memo[0][0] = 1

for idx in range(len(S)):
	ch = S[idx]
	if(ch == '?'):
		for num in range(10):
			for i in range(13):
				if(memo[idx][i] > 0):
					memo[idx+1][(i*10+num)%13] += memo[idx][i] 
	else:
		num = int(ch)
		for i in range(13):
			if(memo[idx][i] > 0):
				memo[idx+1][(i*10+num)%13] += memo[idx][i] 
	
	for i in range(13):
		memo[idx+1][i] %= MOD

print(memo[len(S)][5]%MOD)
### BUGGY CODE ###

number = int(input())
heights = list(map(int, input().split()))
plusminus=[]
answerlist = [0]
for i in range(number-1):
    if heights[i]>=heights[i+1]:
        plusminus.append(1)
    else:
        plusminus.append(0)
for j in range(number-1):
    if heights[j] == 0:
        pass
    else:
        q = 0
        for k in range(number-1-j):
            if plusminus[j+k]==1:
                q += 1
            else:
                break
        answerlist.append(q)
                
print(max(answerlist))

### FIXED CODE ###

number = int(input())
heights = list(map(int, input().split()))
plusminus=[]
answerlist = [0]
q = 0
for i in range(number-1):
    if i != number-2 and heights[i]>=heights[i+1]:
        q += 1
    elif i == number-2 and heights[i]>=heights[i+1]:
        q += 1
        answerlist.append(q)
    else:
        answerlist.append(q)
        q = 0
print(max(answerlist))
### BUGGY CODE ###

"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
def main():
    import sys
    sys.setrecursionlimit(1000000)

    N = int(input())

    A = [[0]*(N)]
    for _ in range(N):
        A.append([0]+list(map(int,input().split())))
    
    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = {i:{} for i in range(1,N+1)}
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j

    matchs = []
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            matchs.append((i,j))

    edges = {}
    for match in matchs:
        edges[match] = []
        i,j = match
        if reverseMemo[i][j] != N-1:
            nx = A[i][reverseMemo[i][j]+1]
            edges[match].append((min(i,nx),max(i,nx)))
        if reverseMemo[j][i] != N-1:
            nx = A[j][reverseMemo[j][i]+1]
            edges[match].append((min(j,nx),max(j,nx)))

    stepMemo = {}
    def dfs(i,j,path):
        #i,jの試合日を含めて、あと何日必要なのかを返す。
        if (i,j) not in stepMemo:
            if (i,j) in path:
                print(-1)
                exit()
            else:
                path.add((i,j))
            res = 1
            for a,b in edges[(i,j)]:
                res = max(res,dfs(a,b,path)+1)
            stepMemo[(i,j)] = res
        return stepMemo[(i,j)]

    ans = 0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            ans = max(ans,dfs(i,j,set()))
    print(ans)
main()

### FIXED CODE ###

"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
def main():
    import sys
    sys.setrecursionlimit(1000000)
    input = sys.stdin.readline

    N = int(input())

    A = [[0]*(N)]
    for i in range(N):
        A.append([0]+list(map(int,input().split())))
    
    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = [[-1]*(N+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j
    edges = {}
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            match = (i,j)
            edges[match] = []
            if reverseMemo[i][j] != N-1:
                nx = A[i][reverseMemo[i][j]+1]
                edges[match].append((min(i,nx),max(i,nx)))
            if reverseMemo[j][i] != N-1:
                nx = A[j][reverseMemo[j][i]+1]
                edges[match].append((min(j,nx),max(j,nx)))
    
    del reverseMemo
    del A
    
    stepMemo = {}
    def dfs(i,j,path):
        #i,jの試合日を含めて、あと何日必要なのかを返す。
        if (i,j) not in stepMemo:
            if (i,j) in path:
                print(-1)
                exit()
            else:
                path.add((i,j))
            res = 1
            for a,b in edges[(i,j)]:
                res = max(res,dfs(a,b,path)+1)
            stepMemo[(i,j)] = res
        return stepMemo[(i,j)]

    ans = 0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if (i,j) not in stepMemo:
                ans = max(ans,dfs(i,j,set()))
    print(ans)
main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10 ** 9 + 7
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += a[i] * a[j] % mod
print(ans % mod)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = [0] * n
s[n - 1] = a[n - 1]
for i in range(n - 2, -1, -1):
    s[i] = s[i + 1] + a[i]
    
ans = 0
mod = 10 ** 9 + 7
for i in range(n - 1):
    ans += a[i] * s[i + 1]
print(ans % mod)
### BUGGY CODE ###

n, a, b = map(int, input().split())
s = input()

ans = ["No"] * n
foreigner = 0

for i in range(n):
    if s[i] == "a":
        ans[i] = "Yes"
    elif s[i] == "b" and foreigner < b:
        ans[i] = "Yes"
        foreigner += 1
    if ans.count("Yes") == a + b:
        break

for i in ans:
    print(i)

### FIXED CODE ###

n, a, b = map(int, input().split())
s = input()

success = 0
foreigner = 0
count = 0

for i in s:
    if i == "a":
        print("Yes")
        success += 1
    elif i == "b" and foreigner < b:
        print("Yes")
        success += 1
        foreigner += 1
    else:
        print("No")
    count += 1
    if success == a + b:
        break

for _ in range(n - count):
    print("No")
### BUGGY CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    X = readline().strip()

    n = int(X, 2)
    p = X.count('1')

    ans = [0] * N
    for i in range(N):
        if X[i] == '1':
            m = n - pow(2, N - i - 1)
            q = p - 1
        else:
            m = n + pow(2, N - i - 1)
            q = p + 1
        
        while m:
            ans[i] += 1
            m %= q
            q = bin(m).count('1')
            
    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    X = readline().strip()
    p = X.count('1')

    power_down = [0] * N
    power_up = [0] * N
    power_down[0] = 1
    power_up[0] = 1
    for i in range(N - 1):
        if p > 1:
            power_down[i + 1] = power_down[i] * 2 % (p - 1)
        power_up[i + 1] = power_up[i] * 2 % (p + 1)

    base_down = base_up = 0
    for i in range(N):
        if X[i] == '1':
            if p > 1:
                base_down = (base_down + power_down[N - i - 1]) % (p - 1)
            base_up = (base_up + power_up[N - i - 1]) % (p + 1)

    ans = [1] * N
    for i in range(N):
        if p == 1 and X[i] == '1':
            ans[i] = 0
            continue

        if X[i] == '1':
            m = (base_down - power_down[N - i - 1]) % (p - 1)
            q = p - 1
        else:
            m = (base_up + power_up[N - i - 1]) % (p + 1)
            q = p + 1

        while m:
            ans[i] += 1
            q = bin(m).count('1')
            m %= q

    print(*ans, sep='\n')
    return


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

from heapq import heappush, heappop
INF = 10 ** 20
def search(item_lst):
  dp = [[INF] * 101 for _ in range(101)]
  dp[0][0] = 0
  que = []
  heappush(que, (0, 0, 0))
  while que:
    score, a, e = heappop(que)
    for da, de in item_lst[e]:
      na, ne = min(d, a + da), min(100, e + de)
      if na == d:
        print(score + 1)
        return True

      if dp[na][ne] > score + 1:
        dp[na][ne] = score + 1
        heappush(que, (score + 1, na, ne))
  
  print("NA")
  return False

while True:
  d, n = map(int, input().split())
  if d == 0:
    break
  item_lst = [[] for _ in range(101)]
  for _ in range(n):
    a, e, r = map(int, input().split())
    for i in range(r, 101):
      item_lst[i].append((a, e))
  search(item_lst)


### FIXED CODE ###

from heapq import heappush, heappop
INF = 10 ** 20

def search(item_lst, d):
  visited = {}
  visited[(0, 0)] = True
  que = []
  heappush(que, (0, 0, 0))
  while que:
    score, a, e = heappop(que)
    for da, de in item_lst[e]:
      na = a + da
      if na >= d:
        print(score + 1)
        return True
      ne = e + de
      if ne > 100:
        ne = 100
      
      if (na, ne) not in visited:
        visited[(na, ne)] = True
        heappush(que, (score + 1, na, ne))
  
  print("NA")
  return False

def main():
  while True:
    d, n = map(int, input().split())
    if d == 0:
      break
    item_lst = [[] for _ in range(101)]
    for _ in range(n):
      a, e, r = map(int, input().split())
      for i in range(r, 101):
        item_lst[i].append((a, e))
    search(item_lst, d)
main()
### BUGGY CODE ###




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


dices = list(map(int, input().split()))


# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > sum(dices[maxpos:maxpos+K]):
        maxpos = pos


# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
ary = list(map(int, input().split()))


# ruisekiwa
ruiseki = [0] * (n+1)

for i, x in enumerate(ary):
    ruiseki[i+1] = ruiseki[i] + x

kmax = 0
for i in range(n+1-k):
    ksum = ruiseki[i+k] - ruiseki[i]
    kmax = max(kmax, ksum)

print((kmax+k) / 2)
### BUGGY CODE ###

s = input()
pos = 0
cnt = 0
if len(s) < 3:
    print(0)
else:
    while(True):
        if s[pos:pos+3] == "ABC":
            s = s[:pos] + "BCA" + s[pos+3:]
            if pos > 0:
                pos -= 1
            cnt += 1
        else:
            if s[pos+1:pos+3] == "AB":
                pos += 1
            elif s[pos+2:pos+3] == "A":
                pos += 2
            else:
                pos += 3
        if pos >= len(s)-2:
            break
    print(cnt)


### FIXED CODE ###

s = input()
pos = 0
cnt = 0
acnt = 0
if len(s) < 3:
    print(0)
else:
    while(True):
        if s[pos:pos+2] == "BC" and acnt > 0:
            pos += 2
            cnt += acnt
            # print(s, s[pos:pos+2], cnt, pos)
        else:
            if s[pos] == "A":
                acnt += 1
            else:
                acnt = 0
            pos += 1
        if pos >= len(s)-1:
            break
    print(cnt)
### BUGGY CODE ###

from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

ans_dict = {}
ans_keys = []
value_dict = {1: 0}
value_keys = [1]
for i in range(n):
    num = a_list[i]
    if num in ans_keys:
        print(int(ans_dict[num]))
    else:
        buff = a_list[:i]
        buff.extend(a_list[i+1:])
        c = Counter(buff)

        tmp_ans = 0
        for value in c.values():
            if value in value_keys:
                tmp_ans += value_dict[value]
            else:
                tmp = (value * (value - 1))/2
                tmp_ans += tmp
                value_dict[value] = tmp
                value_keys.append(value)
        ans_dict[num] = tmp_ans
        ans_keys.append(num)
        print(int(tmp_ans))



### FIXED CODE ###

from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

st=set()
prevset=set()
for i in range(N):
    x,y,h=LI()
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()



inl = [LI() for i in range(N)]
inl.sort(key=lambda x: x[2], reverse=True)

st=set()
prevset=set()
for x,y,h in inl:
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())
### BUGGY CODE ###

n, k = map(int, input().split())
p = [(1 + int(x)) / 2 for x in input().split()]
ans = 0
for i in range(n - k + 1):
    ans = max(ans, sum(p[i: i + k]))
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = [(1 + int(x)) / 2 for x in input().split()]
a_idx, l, r = 0, 0, 0
for i in range(1, n - k + 1):
    l += p[i - 1]
    r += p[i + k - 1]
    if r > l:
        a_idx, l, r = i, 0, 0
print(sum(p[a_idx:a_idx + k]))
### BUGGY CODE ###

N = int(input())
X = input()

#N = 20000
#X = "1"*N

a = int(X, 2)
b = X.count("1")
k = 2 ** (N-1)

for i, ch in enumerate(X):
    if ch == "0":
        x = a + k
        y = b + 1
    else:
        x = a - k
        y = b - 1
    k //= 2

    if x == 0:
        print(0)
    else:
        ans = 1
        t = x % y
        while t > 0:
            t %= bin(t).count("1")
            ans += 1
        print(ans)


### FIXED CODE ###

N = int(input())
X = input()

a = int(X, 2)
b = X.count("1")

if b > 1:
    a1 = a % (b-1)
else:
    a1 = 0
a0 = a % (b+1)

for i in range(N):
    if X[i] == "1":
        if b == 1:
            print(0)
            continue
        t = (a1 - pow(2, N-1-i, b-1)) % (b-1)
    else:
        t = (a0 + pow(2, N-1-i, b+1)) % (b+1)
    
    ans = 1
    while t > 0:
        t %= bin(t).count("1")
        ans += 1
    print(ans)