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

[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	dansu=int((x+y)/3)
	r=y-dansu
	mod=1000000007
	d=1
	rr=1
	nr=1
	for i in range(1,dansu+1):
		d=d*(i%mod)
	for i in range(1,r+1):
		rr=rr*(i%mod)
	for i in range(1,dansu-r+1):
		nr=nr*(i%mod)
	
	kotae=int(d*(rr**(mod-2))*(nr**(mod-2)))
	kotae=int(kotae%(10**9+7))
	
	print(kotae)

### FIXED CODE ###

[x,y]=list(map(int,input().split()))
if ((x%3)+(y%3))%3!=0:
	print(0)
else:
	n=int((x+y)/3)
	r=y-n
	if r<0 or r>n:
		print(0)
	else:
		if r>n-r:
			r=n-r
		mod=1000000007
		kaijo=[1]
		for i in range(1,n+1):
			kaijo.append(kaijo[-1]*i%mod) #これで、kaijo[i]=i!となる。
		gyakugen=[pow(kaijo[n-r],mod-2,mod)]
		for i in reversed(range(1,n-r+1)):
			gyakugen.append(gyakugen[-1]*i%mod) #これで、gyakugen[i]=n-r-iの逆元となる
		kotae=kaijo[n]*gyakugen[0]*gyakugen[n-2*r]%mod

		print(kotae)
### BUGGY CODE ###

x = int(input())
done=False
for a in range(-7000,7001):
  for b in range(-7000,7001):
    if(not done and a**5-b**5==x):
      print(a,b)
      done=True

### FIXED CODE ###


x = int(input())
for a in range(-300,301):
  if(a<0):
    for b in range(-300,a):
      if(a**5-b**5==x):
        print(a,b)
        break
    else: continue
    break
  else:
    for b in range(-300,a):
      if(a**5-b**5==x):
        print(a,b)
        break
    else: continue
    break
### BUGGY CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in a:
    dp[j+2]=dp[j]+dp[j+1]
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
b=set(a)
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in b:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))
### BUGGY CODE ###

import math

def gcd_ext(a, b):
    x, y, lastx, lasty = 0, 1, 1, 0
    while b != 0:
        q = a // b
        a, b = b, a % b
        x, y, lastx, lasty = lastx - q * x, lasty - q * y, x, y
    return (lastx, lasty)

n = int(input())
divisor_list = []
n *= 2
for x in range(2, int(n ** 0.5) + 1):
    if n % x == 0:
        divisor_list.append([x, n // x])
ans = n - 1
for m1, m2 in divisor_list:
    if math.gcd(m1, m2) != 1:
        continue
    p, q = gcd_ext(m1, m2)
    tmp = (-1 * m1 * p) % (m1 * m2)
    ans = min(tmp, ans)
    tmp = (-1 * m2 * q) % (m1 * m2)
    ans = min(tmp, ans)
print(ans)

### FIXED CODE ###

import math

def gcd_ext(a, b):
    x, y, lastx, lasty = 0, 1, 1, 0
    while b != 0:
        q = a // b
        a, b = b, a % b
        x, y, lastx, lasty = lastx - q * x, lasty - q * y, x, y
    return (lastx, lasty)

n = int(input())
divisor_list = []
n *= 2
for x in range(2, int(n ** 0.5) + 1):
    if n % x == 0:
        divisor_list.append([x, n // x])
ans = n - 1
for m1, m2 in divisor_list:
    if math.gcd(m1, m2) != 1:
        continue
    p, q = gcd_ext(m1, m2)
    tmp = (-1 * m1 * p) % (m1 * m2)
    ans = min(tmp, ans)
    tmp = (-1 * m2 * q) % (m1 * m2)
    ans = min(tmp, ans)
print(ans)
### BUGGY CODE ###

N=int(input())
S=list(map(int,input().split()))
S.sort()
S.reverse()
p = [S.pop(0)]
c = S
f = False

for i in range(N):
    np = []
    nc = []
    for j in range(len(p)):
        for k in range(len(c)):
            if c[k] < p[j]:
                np.append(c.pop(k))
                f = True
                break
        if f == False:
            print("No")
            exit(0)
        f = False
    p += np
    p.sort()
    p.reverse()

print("Yes")

### FIXED CODE ###

N=int(input())
S=list(map(int,input().split()))
S.sort()
p = [S.pop(-1)]
r = S

for i in range(N):
    nr = []
    for p_ in p[::-1]:
        while r:
            r_ = r.pop()
            if r_ < p_:
                p.append(r_)
                break
            nr.append(r_)
    p.sort()
    r+=nr[::-1]

print("Yes" if len(r)==0 else "No")
### BUGGY CODE ###

h,w,d=map(int,input().split())
nums=[[0 for s in range(w)] for i in range(h)]
gya=[[0,0] for i in range(h*w)]
for i in range(h):
    nums[i]=list(map(int,input().split()))
    for j in range(w):
        gya[nums[i][j]-1]=[i,j]
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    m=(r-l)//d
    ans=0
    for j in range(1,m+1):
        ans+=abs(gya[l+j*d-1][0]-gya[l+d*(j-1)-1][0])+abs(gya[l+j*d-1][1]-gya[l+d*(j-1)-1][1])
    print(ans)


### FIXED CODE ###

h,w,d=map(int,input().split())
nums=[[0 for s in range(w)] for i in range(h)]
gya=[[0,0] for i in range(h*w)]
for i in range(h):
    nums[i]=list(map(int,input().split()))
    for j in range(w):
        gya[nums[i][j]-1]=[i,j]
cost=[0]*(h*w+d)
for i in range(d):
    s=i
    while s<h*w-d:
        cost[s+d]=cost[s]+abs(gya[s+d][0]-gya[s][0])+abs(gya[s+d][1]-gya[s][1])
        s+=d
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(cost[r-1]-cost[l-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import math

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

def check(l):
    for i in l:
        if (i[0] == '1'):
            for j in l:
                if (j == [i[1], str(N)]):
                    return('POSSIBLE')
    return('IMPOSSIBLE')

print(check(li))


### FIXED CODE ###

# -*- coding: utf-8 -*-

import math

N, M = map(int, input().split())
start = [False] * N
goal = [False] * N
for i in range(M):
    a1, a2 = map(int, input().split())
    if (a1 == 1):
        start[a2 - 1] = True
    if (a2 == N):
        goal[a1 - 1] = True

def check():
    for i in range(N):
        if (start[i] & goal[i]):
            return('POSSIBLE')
    return('IMPOSSIBLE')

print(check())
### BUGGY CODE ###

S=input()
# S="".join(["1" for _ in range(10**5)])
# S = "??2??5"
# S= "?44"

MOD = 10**9+7
dp = {}
for i in range(13):
    dp[(-1,i)] = 0
dp[(-1,0)] = 1
for t,ss in enumerate(S[::-1]):
    if t==0:
        tt = 1
    else:
        tt = (10*tt)%13
    for i in range(13):
        dp[(t,i)] = 0
    if ss=="?":
        for i in range(13):
            for j in range(10):
                k = (t,(j*tt+i)%13)
                dp[k] = (dp[k]+dp[(t-1,i)])%MOD
    else:
        s = int(ss)
        for i in range(13):
            k = (t,(s*tt+i)%13)
            dp[k] = (dp[(t-1,i)] + dp[k])%MOD

print(dp[(t,5)])

### FIXED CODE ###

S=input()
# S="".join(["?" for _ in range(10**5)])
# S = "??2??5"
# S= "?44"

MOD = 10**9+7
dp = [[0 for i in range(13)] for j in range(len(S)+1)]
dp[0][0] = 1
for t,ss in enumerate(S[::-1]):
    if t==0:
        tt = 1
    else:
        tt = (10*tt)%13
    if ss=="?":
        for i in range(13):
            for j in range(10):
                k = (j*tt+i)%13
                dp[t+1][k] += dp[t][i]%MOD
    else:
        s = int(ss)
        for i in range(13):
            k = (s*tt+i)%13
            dp[t+1][k] += dp[t][i]%MOD

print(dp[t+1][5]%MOD)
### BUGGY CODE ###

S = list(input())
n = len(S)
res = 0
cur = 0
count = [0] * 2020
for i, c in enumerate(map(int, S)):
    cur = cur * 10 + c
    if cur % 2019 == 0:
        res += 1
    temp = (cur * 10 ** (n - i)) % 2019
    res += count[temp]
    count[temp] += 1
print(res)

### FIXED CODE ###

S = list(input())
n = len(S)
cur = 0
count = [0] * 2020
count[0] = 1
for i, c in enumerate(map(int, S[::-1])):
    cur = (cur + c * pow(10, i, 2019)) % 2019
    count[cur] += 1
    
print(sum(c * (c - 1) // 2 for c in count))
### BUGGY CODE ###


H, W, D = map(int, input().split())

coord_dict = {}
for i in range(H):
    gyo = [int(i) for i in input().split()]
    for j in range(W):
        coord_dict.update({gyo[j] : (i,j)})
        
Q = int(input())

"""
exam = [[] for i in range(Q)]
for i in range(Q):
    exam[i] = [int(i) for i in input().split()]
"""
exam = [[int(i) for i in input().split()] for i in range(Q)]

for i in range(Q):
    reduce_MP = 0
    num = exam[i][0]
    coord1 = coord_dict[num]
    while num < exam[i][1]:
        num += D
        coord2 = coord_dict[num]
        reduce_MP += abs(coord1[0] - coord2[0]) + abs(coord1[1] - coord2[1])
        coord1 = coord2
    print(reduce_MP)



### FIXED CODE ###

H, W, D = list(map(int, input().split()))

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

xx = [0 for i in range(90002)]
yy = [0 for i in range(90002)]
for y in range(H):
    for x in range(W):
        xx[Amap[y][x]] = x
        yy[Amap[y][x]] = y
Q = int(input())

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

# magic point calculation
mp = [0 for i in range(90002)]

for i in range(D+1, 90002):
    mp[i] = mp[i-D] + abs(xx[i] -xx[i-D]) + abs(yy[i] - yy[i-D])

for i in coord:
    print(mp[i[1]] - mp[i[0]])
### BUGGY CODE ###

from itertools import permutations

def cal():
    d, g = map(int, input().split())
    a = list(permutations([[i+1]+list(map(int, input().split())) for i in range(d)]))
    ans = float('inf')

    for i in a:
        val, count = g, 0
        for a, b, c in i:
            num = 100*a*b
            if num+c >= val:
                if num >= val:
                    count += val//(100*a)
                else:
                    count += b
                break
            else:
                count += b
                val -= num+c
            if count >= ans:
                break
        ans = min(ans, count)
    print(ans)

cal()


### FIXED CODE ###

def cal():
    d, g = map(int, input().split())
    a = [list(map(int, input().split())) for i in range(d)]
    ans = float('inf')

    for i in range(2**d):
        b = ['-']*d
        for j in range(d):
            if (i>>j)&1:
                b[j] = '+'
        count0, count1 = 0, 0
        for j in range(d):
            if b[j] == '+':
                count0 += 100*(j+1)*a[j][0]+a[j][1]
                count1 += a[j][0]
        if count0 < g:
            for j in range(d-1, -1, -1):
                if b[j] == '-':
                    for k in range(a[j][0]):
                        if count0 >= g:
                            break
                        count0 += 100*(j+1)
                        count1 += 1
        ans = min(ans, count1)
    print(ans)
cal()
### BUGGY CODE ###

L,R = map(int, input().split())
X = L * R
min = 2018
for i in range(L,R):
    for j in range(i+1,R+1):
        n = (i*j)%2019
        if n<min:
            min = n
print(min)

### FIXED CODE ###

L,R = map(int, input().split())
x = L // 2019
y = R // 2019
if y-x>0:
    min=0
else:
    min = 2018
    for i in range(L,R):
        for j in range(i+1,R+1):
            n = (i*j)%2019
            if n<min:
                min= n
print(min)
### BUGGY CODE ###

N,A=map(int, input().split())
x=[int(x) for x in input().split()]
x.sort()
W=sum(x)
dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)]
for j in range(N+1):
    dp[j][0][0]=1
for j in range(1,N+1):
    xj=x[j-1]
    for k in range(1, N+1):
        for s in range(1, W+1):
            if s<xj:
                dp[j][k][s]=dp[j-1][k][s]
            else:
                dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-xj]

ans=0
for k in range(1,N+1):
    if k*A<=W:
        ans+=dp[N][k][k*A]
print(ans)


### FIXED CODE ###

import sys
from sys import stdin
input = stdin.readline

def solve(N, A, x):
    W=sum(x)
    dp=[[[0]*(W+1) for _ in range(N+1)] for _ in range(N+1)]
    for j in range(N+1):
        dp[j][0][0]=1
    for j in range(1,N+1):
        xj=x[j-1]
        for k in range(1, N+1):
            for s in range(1, W+1):
                if s<xj:
                    dp[j][k][s]=dp[j-1][k][s]
                else:
                    dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-xj]

    ans=0
    for k in range(1,N+1):
        if k*A<=W:
            ans+=dp[N][k][k*A]
        else:
            break
    return ans


def main(args):
    N,A=map(int, input().split())
    x=[int(x) for x in input().split()]
    ans=solve(N,A,x)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

# D - Various Sushi
import sys
from collections import defaultdict
import heapq
readline = sys.stdin.readline

dd = defaultdict(list)
N, K = map(int, readline().split())
for i in range(N):
    t, d = map(int, readline().split())
    heapq.heappush(dd[t], d*-1)

dd = list(dd.values())
dd.sort()

ans = 0
fix = 0
var = []
for i in range(len(dd)):
    fix += heapq.heappop(dd[i]) * -1
    for _ in range(K-(i+1)):
        if len(dd[i]) > 0:
            tmp = heapq.heappop(dd[i]) * -1
            heapq.heappush(var, tmp)
    while len(var) > K-(i+1) and len(var) > 0:
        heapq.heappop(var)
    if len(var) == K-(i+1):
        ans = max(ans , fix+sum(var) + (i+1)**2)

print(ans)

### FIXED CODE ###

# D - Various Sushi
import sys
from collections import defaultdict
import heapq

readline = sys.stdin.readline

dd = defaultdict(list)
N, K = map(int, readline().split())
for i in range(N):
    t, d = map(int, readline().split())
    heapq.heappush(dd[t], d*-1)

dd = list(dd.values())
dd.sort()

ans = 0
fix = 0
var = []
len_var = 0
sum_var = 0
tmp_max = 0

for i in range(min(K, len(dd))):
    fix += heapq.heappop(dd[i]) * -1
    for _ in range(len(dd[i])):
        tmp = heapq.heappop(dd[i]) * -1
        heapq.heappush(var, tmp)
        len_var += 1
        sum_var += tmp
    while len_var > K-(i+1) and len_var > 0:
        del_var = heapq.heappop(var)
        len_var -= 1
        sum_var -= del_var
    if len_var == K-(i+1):
        ans = max(ans , fix+sum_var + (i+1)**2)

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

n = int(input())
a = list(map(int,input().split()))
ans = 1
j = 0
for i in range(n):
    ans *= a[i]
    if 0 in a:
        j += 2
        break
    if ans > 10**18:
        j += 1
        break
if j == 2:
    print(0)
elif j == 1:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(str,input().split()))
ans = 1
b = Counter(a)
b0 = 0
b1 = 0

if '0' in a:
    b0 = b['0']
if '1' in a:
    b1 = b['1']
more2 = n-b0-b1
if b0 >0:
    print(0)
elif more2 >=60:
    print(-1)
else:
    for i in range(n):
        ans *= int(a[i])
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
### BUGGY CODE ###

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

DP = [0]*(N+1)
DP[1] = 1

S = set()
for i in range(K):
    l, r = map(int, input().split())
    for j in range(l, r+1):
      S.add(j)

S = sorted(list(S))

for i in range(1, N+1):
    for d in S:
        if i + d <= N:
            DP[i+d] += DP[i]%998244353

print(DP[N]%998244353)

### FIXED CODE ###

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

DP = [0]*(N+1)
DP[1] = 1

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

for i in range(2, N+1):
    for l, r in S:
            DP[i] += (DP[max(i-l, 0)] - DP[max(i-r-1, 0)])
    DP[i] += DP[i-1]
    DP[i] %= 998244353

print((DP[N] - DP[N-1])%998244353)
### BUGGY CODE ###

from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N=int(input())
T=[int(input()) for i in range(N)]
lst1={}
for t in T:
    Z=Counter(prime_factorize(t))
    #print(Z)
    for z in Z:

        if str(z) not in lst1:
            lst1.update({str(z):Z[z]})
        else:
            lst1[str(z)]=max(lst1[str(z)],Z[z])
#print(lst1)
count=1
for l in lst1:
    count*=int(l)**lst1[l]
print(count)


### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions .gcd(x, y)


N=int(input())
T=[int(input()) for i in range(N)]
temp=T[0]
for i in range(1,N):
    temp=lcm(temp,T[i])

print(temp)
### BUGGY CODE ###

N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
ans = 0
for X in range(1,2**len(D)):
  k = format(X,'b').zfill(len(D))
  cur = 1
  for i in range(len(k)):
    if k[i] == '1':
      cur *= (D[i]%(10**9+7))
  ans += (cur%(10**9+7))
print(ans%(10**9+7))

### FIXED CODE ###

N = int(input())
S = input()
L = [chr(ord('a') + i) for i in range(26)]
cnt = [0]*26
for i in range(len(S)):
  cnt[ord(S[i])-97] += 1
D = []
for i in range(26):
  if cnt[i] != 0:
    D.append(cnt[i])
ans = 1
for i in range(len(D)):
  ans *= (D[i]+1)
  ans = ans%(10**9+7)
print((ans-1)%(10**9+7))
### BUGGY CODE ###

n, m = map(int, input().split())
edges = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a-1 in edges:
    edges[a-1].append(b-1)
  else:
    edges[a-1] = [b-1]
  if b-1 in edges:
    edges[b-1].append(a-1)
  else:
    edges[b-1] = [a-1]

end1, end2 = a-1, b-1

visited = [False for _ in range(n)]
visited[end1] = True
visited[end2] = True

seti = set([end1, end2])
path = [end1, end2]
while True:
  reme = None
  for _a in edges[end1]:
    if _a not in seti:
      reme = _a
      break
  if reme is not None:
    end1 = _a
    seti.add(_a)
    path = [_a] + path
  else:
    for _a in edges[end2]:
      if _a not in seti:
        reme = _a
        break
    if reme is not None:
      end2 = _a
      seti.add(_a)
      path += [_a]
  if reme is None:
    break

print(len(path))
print(*map(lambda x: x+1, path))


### FIXED CODE ###

n, m = map(int, input().split())
edges = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a-1 in edges:
    edges[a-1].append(b-1)
  else:
    edges[a-1] = [b-1]
  if b-1 in edges:
    edges[b-1].append(a-1)
  else:
    edges[b-1] = [a-1]

end1, end2 = a-1, b-1

visited = [False for _ in range(n)]
visited[end1] = True
visited[end2] = True

seti = set([end1, end2])
path = [end1, end2]
while True:
  reme = None
  for _a in edges[end1]:
    if _a not in seti:
      reme = _a
      break
  if reme is not None:
    end1 = _a
    seti.add(_a)
    path = [_a] + path
  else:
    for _a in edges[end2]:
      if _a not in seti:
        reme = _a
        break
    if reme is not None:
      end2 = _a
      seti.add(_a)
      path += [_a]
  if reme is None:
    break

print(len(path))
print(*map(lambda x: x+1, path))
### BUGGY CODE ###

N,K = map(int,input().split())
flag = 0
a = 1
while a <= N:
  b = 1
  while b <= a:
    c = 1
    while c <= b:
      if (a+b)%K == 0 and (b+c)%K == 0 and (c+a)%K == 0:
        if a == b and b == c:
          flag = flag + 1
        elif a == b or b == c or c == a:
          flag = flag + 3
        else:
          flag = flag + 6
      c = c + 1
    b = b + 1
  a = a + 1
print(flag)

### FIXED CODE ###

N,K = map(int,input().split())
if K%2==1:
    maxn = int(N/K)
    print(maxn**3)
else:
    maxn=int(N/K)
    if N%K >= int(K/2):
        print(maxn**3+(maxn+1)**3)
    else:
        print(2*maxn**3)
### BUGGY CODE ###

import bisect
n,m=map(int,input().split())
l=[[] for _ in range(m)]
for _ in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(b)
ans=0
w=[]
for i in range(m):
  for j in l[i]:
    bisect.insort_right(w,j)
  if w!=[]:
    ans+=w.pop(-1)
print(ans)

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
l=[[] for _ in range(m)]
for _ in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l[a-1].append(b)
ans=0
w=[]
for i in range(m):
  for j in l[i]:
    heapq.heappush(w,-j)
  if w!=[]:
    ans-=heapq.heappop(w)
print(ans)
### BUGGY CODE ###

h, n = map(int, input().split())
l = []
for i in range(n):
  a, b = map(int, input().split())
  l.append([a, b])

dp = [10 ** 9 for i in range(h+1)]

for i in range(h+1):
  for j in range(n):
    if l[j][0] >= i:
      if dp[i] > l[j][1]:
        dp[i] = l[j][1]
    else:
      if dp[i] > l[j][1] + dp[i-l[j][0]]:
        dp[i] = l[j][1] + dp[i-l[j][0]]


print(dp[h])


### FIXED CODE ###

def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    dp = [100000000] * (H + 10 ** 4 + 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == 100000000:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()
### BUGGY CODE ###

n=int(input())
A = [int(x) for x in input().split()]

ans =A[0]

for i in A[1:]:

    ans = ans * i

if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import sys
n=int(input())
A = [int(x) for x in input().split()]
bar = 10**18
ans =A[0]
if 0 in A:
    print(0)
    sys.exit()
    
for i in A[1:]:
    ans = ans * i
    if ans > bar:
        print(-1)
        sys.exit()
        
print(ans)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
lr = []
cnt = []
for i in range(Q):
        lr.append(list(map(int,input().split())))

for k in range(len(S)):
    if k - 1 >= 0:
        if S[(k - 1):(k + 1)] == 'AC':
                cnt.append(1)
        else:
                cnt.append(0)

for lrs in lr:
        print(sum(cnt[lrs[0]-1:lrs[1]-1]))       


### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
cnt = [0] * (N + 1)
lrs = []
for i in range(Q):
        lrs.append(list(map(int,input().split())))

for i in range(N):
        cnt[i+1] = cnt[i] + (1 if S[i:i+2] == "AC" else 0)
for lr in lrs:
        print(cnt[lr[1] - 1] - cnt[lr[0] - 1])
### BUGGY CODE ###

from collections import defaultdict

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        S = input()
        d[S] += 1

    ans = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
    ans.sort()
    for a in ans:
        print(a)
    
    



if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import defaultdict

def main():
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        S = input()
        d[S] += 1

    max_d = max(d.values())
    ans = []
    for key, value in d.items():
        if value == max_d:
            ans.append(key)
    ans.sort()
    for a in ans:
        print(a)
    
    



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

# coding: utf-8
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def f(i):
    if dp[i]:
        return(False)
    dp[i] = 1
    for u in U[i]:
        if f(u):
            dp[i] = dp[i] * (dp[u] + 1)
    return(True)

N, M = map(int, input().split()) # 1 <= N <= 10^5, 2 <= M <= 10^9
U = [set() for _ in range(N)]
for x, y in [map(int, input().split()) for _ in range(N - 1)]:
    U[x - 1].add(y - 1)
    U[y - 1].add(x - 1)
# print(U)
for i in range(N):
    dp = [0] * N
    f(i)
    print(dp[i] % M)


### FIXED CODE ###

# coding: utf-8

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

def dfs(v, p = -1):
    deg[v] = len(U[v])
    dp[v] = [0] * deg[v]
    ans = 1
    for i in range(deg[v]):
        u = U[v][i]
        if u == p:
            par[v] = i
            continue
        dp[v][i] = dfs(u, v)
        ans *= dp[v][i] + 1
        ans %= M
    return(ans)

def bfs(v, ans_p = 0, p = -1):
    if p != -1:
        dp[v][par[v]] = ans_p
    lmul = [1] * (deg[v] + 1)
    rmul = [1] * (deg[v] + 1)
    for i in range(1, deg[v] + 1):
        lmul[i] = lmul[i - 1] * (dp[v][i - 1] + 1) % M
        rmul[-i - 1] = rmul[-i] * (dp[v][-i] + 1) % M
    ans[v] = rmul[0]
    for i in range(deg[v]):
        u = U[v][i]
        if u == p:
            continue
        bfs(u, lmul[i] * rmul[i + 1] % M, v)

N, M = map(int, input().split()) # 1 <= N <= 10^5, 2 <= M <= 10^9
U = [list() for _ in range(N)]
for x, y in [map(int, input().split()) for _ in range(N - 1)]:
    U[x - 1].append(y - 1)
    U[y - 1].append(x - 1)
deg = [0] * N
par = [0] * N
dp = [None] * N
ans = [0] * N
dfs(0)
bfs(0)
print("\n".join([str(x) for x in ans]))