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

n, m = list(map(int, input().split()))
root_list = []
for _ in range(m):
    root_list.append(list(map(int, input().split())))

answer_list = [0] * (n-1)
done_list = [1]
already_list = [1]
while len(root_list) > 0 and 0 in answer_list:
    if len(done_list) == 0:
        break
    tmp_list = []
    copy_root_list = root_list.copy()
    for num in done_list:
        for l in root_list:
            if l[1] == num:
                if answer_list[int(l[0]-2)] == 0:
                    answer_list[int(l[0]-2)] = num
                    tmp_list.append(l[0])
                    already_list.append(l[0])
                    copy_root_list.remove(l)
                else:
                    copy_root_list.remove(l)
            elif  l[0] == num and l[0] != l[1]:
                if answer_list[int(l[1]-2)] == 0:
                    answer_list[int(l[1]-2)] = num
                    tmp_list.append(l[1])
                    already_list.append(l[1])
                    copy_root_list.remove(l)
                else:
                    copy_root_list.remove(l)
    copy_root_list = [i for i in copy_root_list if (i[0] not in already_list or i[1] not in already_list)]
    root_list = copy_root_list
    done_list = tmp_list

if 0 not in answer_list:
    print("Yes")
    for i in answer_list:
        print(int(i))
else:
    print("No")
    

### FIXED CODE ###

from collections import deque

n, m = list(map(int, input().split()))
root_dict = {}

for _ in range(m):
    a, b = list(map(int, input().split()))
    if a not in root_dict:
        root_dict[a] = deque([b])
    else:
        root_dict[a].append(b)
    if b not in root_dict:
        root_dict[b] = deque([a])
    else:
        root_dict[b].append(a)

visited = [1] + [-1] * (n-1)

done = deque([1])

while done:
    x = done.popleft()
    while root_dict[x]:
        i = root_dict[x].popleft()
        if visited[i-1] < 0:
            visited[i-1] = x
            done.append(i)

if -1 in visited:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(visited[i])
### BUGGY CODE ###

X, Y, Z, K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0
ans = []
ans2 = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
for i in range(X):
    for j in range(Y):
        sum = A[i] + B[j]
        ans.append(sum)
ans.sort(reverse=True)

for i in range(min(K,len(ans))):
    for j in range(Z):
        sum = ans[i] + C[j]
        ans2.append(sum)
ans2.sort(reverse=True)

for l in range(K):
    print(ans2[l])


### FIXED CODE ###

X, Y, Z, K = map(int,input().split())
A = sorted(list(map(int, input().split())),reverse=True)
B = sorted(list(map(int, input().split())),reverse=True)
C = sorted(list(map(int, input().split())),reverse=True)

ans = []

for i in range(X):
    for j in range(Y):
        if (i+1)*(j+1) > K:
            break
        for t in range(Z):
            if (i+1)*(j+1)*(t+1) > K:
                break
            ans.append(A[i]+B[j]+C[t])
ans.sort(reverse=True)

for l in range(K):
    print(ans[l])
### BUGGY CODE ###

N,M = list(map(int,input().split(' ')))
 
abp = []
 
for i in range(M):
	a,b = list(map(int,input().split(' ')))
	abp.append([a,b])
 
abp.sort(key=lambda x:x[1])
 
dbridge = []
 
def check(a,b,dbridge):
	for i in range(a,b):
		if i in dbridge:
			return False
	return True

for a,b in abp:
	if check(a,b,dbridge):
		dbridge.append(b-1)
	else:
		pass
 
print(len(dbridge))


### FIXED CODE ###

N,M = list(map(int,input().split(' ')))
 
abp = []
 
for i in range(M):
	a,b = list(map(int,input().split(' ')))
	abp.append([a,b])
 
abp.sort(key=lambda x:x[1])
 
ep = 0
ans = 0 
for a,b in abp:
	if a >= ep:
		ep = b
		ans = ans + 1

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

S = input()
T = ''
i = 0

while len(T) < len(S):
    if S[i:i+6] == 'eraser':
        T += 'eraser'
        i += 6
    elif S[i:i+5] == 'erase':
        T += 'erase'
        i += 5
    elif S[i:i+5] == 'dream':
        if S[i+5:i+6] == 'd':
            T += 'dream'
            i += 5
        elif S[i+5:i+8] == 'era':
            T += 'dream'
            i += 5
        elif S[i+5:i+6] == '':
            T += 'dream'
            i += 5
        elif S[i+5:i+8] == 'ere':
            T += 'dreamer'
            i += 7
        elif S[i+5:i+8] == 'erd':
            T += 'dreamer'
            i += 7
        elif S[i+5:i+8] == 'er':
            T += 'dreamer'
            i += 7
    else:
        print('NO')
        exit()

print('YES')

### FIXED CODE ###

S = input()
T = ''
i = 0

while len(T) < len(S):
    if S[i:i+6] == 'eraser':
        T += 'eraser'
        i += 6
    elif S[i:i+5] == 'erase':
        T += 'erase'
        i += 5
    elif S[i:i+5] == 'dream':
        if S[i+5:i+6] == 'd':
            T += 'dream'
            i += 5
        elif S[i+5:i+8] == 'era':
            T += 'dream'
            i += 5
        elif S[i+5:i+6] == '':
            T += 'dream'
            i += 5
        elif S[i+5:i+8] == 'ere':
            T += 'dreamer'
            i += 7
        elif S[i+5:i+8] == 'erd':
            T += 'dreamer'
            i += 7
        elif S[i+5:i+8] == 'er':
            T += 'dreamer'
            i += 7
        else:
            T += 'dream'
            i += 5
    else:
        print('NO')
        exit()

print('YES')
### BUGGY CODE ###

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    b = list(map(int, input().split()))
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)

  if check(b) != True:
    print(-1)
    
def check(B):
  if 'get_ipython' in globals(): print(B)
  lenB = len(B)
  if lenB == 0 :
    return True
  for i in range(lenB):
    if B[i] == i+1:
      if check(B[:i]+B[(i+1):]) == True:
        print(B[i])
        return True
    
main()

### FIXED CODE ###

import sys

def main():
  if 'get_ipython' not in globals():  
    # For Subsession
    N = int(input())
    b = [int(i) for i in input().split()] 
  else:
    # b = [1,2,1]
    # b = [2,2]
    b = [1,1,1,2,2,1,2,3,2]
    N = len(b)

  ans = []
  while True:
    for i in range(N-1,-1,-1):
      if b[i] == i+1:
        ans.append(i+1)
        del b[i]
        N = N -1
        break
      if i == 0:
        print(-1)
        sys.exit()
    if N == 0:
      break

  for i in reversed(ans):
    print(i)
    
main()
### BUGGY CODE ###

N,K = map(int, input().split())
li=[]
for i in range(N):
    a,b = map(int, input().split())
    for j in range(b):
        li.append(a)
li.sort()
print(li[K-1])

### FIXED CODE ###

N,K=map(int,input().split())
AB=[[0,0]for _ in range(N)]

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

ans=0
i=0
while K>0 and i<N:
    K-=AB[i][1]
    ans=AB[i][0]
    i+=1

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

a,b,c,k = map(int, input().split())
ans = 0
l = [a,b,c]
while k>0:
    if k < a:
        ans=k
        break
    else:
        ans += a 
        k-=a  
        a-=a 
    if k ==0:
        break    
    if k > b:
        k-=b
        b-=b
    else:
        k-=k
        b-=k    
    if k ==0:
        break    
    if k < c:
        ans += -k 
        k-=k
        break
    
print(ans)

### FIXED CODE ###

a,b,c,k = map(int, input().split())
ans = 0
l = [a,b,c]
while k>0:
    if k < a:
        ans=k
        break
    else:
        ans += a 
        k-=a  
        a-=a 
    if k ==0:
        break    
    if k > b:
        k-=b
        b-=b
    else:
        k-=k
        b-=k    
    if k ==0:
        break    
    if k < c:
        ans += -k 
        k-=k
    else:
        ans += -c
        k -= c
    if k ==0:
        break 
print(ans)
### BUGGY CODE ###

import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,W = IL()
w = [0]
v = [0]

for i in range(N):
  a,b = IL()
  w.append(a)
  v.append(b)
  
# dp[i][w] = v
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
  for j in range(1,W+1):
    if j < w[i]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i])  # max(iの品を使わない時, iの品を使う時)

print(dp[N][W])

### FIXED CODE ###

N,W = list(map(int,input().split()))
w = [0]
v = [0]

for i in range(N):
  a,b = list(map(int,input().split()))
  w.append(a)
  v.append(b)
  
# dp[i][w] = v
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(1,N+1):
  for j in range(1,W+1):
    if j < w[i]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i])  # max(iの品を使わない時, iの品を使う時)

print(dp[N][W])
### BUGGY CODE ###

def main():
    N=int(input())
    A = list(map(int, input().split()))
    ans=[0]*N
    for i in range(N):
        ans[i]=str(A.index(i+1)+1)
    print(' '.join(ans))
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    N=int(input())
    A = list(map(int,input().split()))
    ans=[None]*N
    i=1
    for a in A:
        ans[a-1]=str(i)
        i+=1
    print(' '.join(ans))

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

S=input()
N=len(S)+1
sum=0

for i in range(0,N) :
  l_cnt=0
  r_cnt=0
  for j in range(i-1,-1,-1):
    #print(j)
    if S[j]=="<":
      l_cnt +=1
    else:
      break
  for k in range(i,N-1):
    #print("k=",k,S[k])
    if S[k]==">":
      r_cnt +=1
    else:
      break
  #print(l_cnt,r_cnt)
  sum += max(l_cnt,r_cnt)
  
print(sum)

### FIXED CODE ###

S=input()
N=len(S)+1
cnt=0

# 「<」 がここから左に何個連続しているか
small_left=[1 if S[0]=="<" else 0]
# 「>」 がここから右に何個連続しているか
large_right=[1 if S[-1]==">" else 0]

for i in range(1,len(S)):
  if S[i]=="<":
    small_left.append(small_left[-1]+1) 
  else:
    small_left.append(0) 
    
for i in range(len(S)-2,-1,-1):
  if S[i]==">":
    large_right.append(large_right[-1]+1) 
  else:
    large_right.append(0) 
large_right = large_right[::-1]
#print(large_right,small_left)

cnt += large_right[0]
for i in range(1,N-1):
  cnt += max(large_right[i], small_left[i-1])
cnt += small_left[-1]

print(cnt)
### BUGGY CODE ###

A, B, K = [int(i) for i in input().split()]
for i in range(K):
    if A:
        A -= 1
    elif B:
        B -= 1
print(A, B)

### FIXED CODE ###

A, B, K = [int(i) for i in input().split()]
if K > A:
    K -= A
    A = 0
    if K > B:
        print(0, 0)
    else:
        print(A, B-K)
else:
    print(A-K, B)
### BUGGY CODE ###

s=input()
k=int(input())
st=[[] for i in range(26)]
n=len(s)
for i in range(n):
    st[ord(s[i])-97].append(i)

pre=0
now=set()
for i in st:
    for v in i:
        for c in range(v+1,n+1):
            now.add(s[v:c])
    if len(now)+pre<k:pre+=len(now);now=set()
    else:
        print(sorted(list(now))[k-pre-1]);exit()

### FIXED CODE ###

s=input()
k=int(input())
st=[[] for i in range(26)]
n=len(s)
for i in range(n):
    st[ord(s[i])-97].append(i)

pre=0
now=set()
for i in st:
    for v in i:
        for c in range(v+1,min(n+1,v+6)):
            now.add(s[v:c])
    if len(now)+pre<k:pre+=len(now);now=set()
    else:
        print(sorted(list(now))[k-pre-1]);exit()
### BUGGY CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
len_s=len(s)
dic=defaultdict(int)
ans=0
for i in range(len_s):
    if 2019-int(s[i]) in dic:
        ans+=dic[2019-int(s[i])]
    newdic=defaultdict(int)
    for j in dic.keys():
        newdic[(j*10+int(s[i])*10)%2019]+=dic[j]
    dic=newdic
    dic[int(s[i])*10]+=1
    # print(dic)
print(ans)

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s=input()
len_s=len(s)
lst=[0]
dic=defaultdict(int)
dic[0]=1
ten=1
for i in range(len_s):
    lst.append((lst[i]+int(s[-i-1])*pow(10,i,2019))%2019)
    # ten=ten*10%2019
    dic[lst[-1]]+=1
# print(lst)
# print(dic)
ans=0
for i in dic.values():
    ans+=i*(i-1)//2
print(ans)
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
L=[]
for i in range(N+1):
  L.append(S.count('AC',0,i))
for j in range(Q):
  l,r=map(int,input().split())
  print(L[r]-L[l])

### FIXED CODE ###

N,Q=map(int,input().split())
S=input()
L=[0]
T=0
for i in range(N-1):
  T+=S.count('AC',i,i+2)
  L.append(T)
for j in range(Q):
  l,r=map(int,input().split())
  print(L[r-1]-L[l-1])
### BUGGY CODE ###

s = input()
K = int(input())

known = set()
from heapq import *
hq = []
for i in range(len(s)):
    for j in range(len(s), i, -1):
        ss = s[i:j]
        if ss in known:
            break
        heappush(hq, ss)
        known.add(ss)
for i in range(K-1):
    heappop(hq)
print(heappop(hq))

### FIXED CODE ###

s = input()
K = int(input())

def f(s, K):
    known = set()
    for i in range(len(s)):
        for j in range(min(len(s), i + 5), i, -1):
            ss = s[i:j]
            if ss in known:
                break
            known.add(ss)
    return sorted(known)[K -1]

print(f(s, K))
### BUGGY CODE ###

K,S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if S == x+y+z:
                ans += 1

print(ans)

### FIXED CODE ###

K,S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <= K:
            ans += 1

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

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

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

d.sort()
t.sort()

p = 0
for i in range(len(t)):
    for j in range(p,len(d)):
        if(t[i] == d[j]):
            t[i] = 0
            d[j] = 0
            p = j
            
print('YES' if sum(t) == 0 else 'NO')

### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

dc = collections.Counter(d)
tc = collections.Counter(t)
s = [0 for i in range(len(tc))]
for i,index in enumerate(tc):
    s[i] = dc[index]-tc[index]
    

print('YES' if all(list(map(lambda x : x >= 0 , s))) else 'NO')
### BUGGY CODE ###

a,b,x=map(int,input().split())
def water(a,b,x):
  import math
  if math.tan(math.radians(x))<=b/a:
    return (((a**2)*math.tan(math.radians(x))))/2+a*(b-a*math.tan(math.radians(x)))
  else:
    return b**2/(2*math.tan(math.radians(x)))

p=0
q=90
r=0
while r<=1000000:
  if water(a,b,(p+q)/2)<=x/a:
    p=p
    q=(p+q)/2
    r=r+1
  else:
    p=(p+q)/2
    q=q
    r=r+1

print((p+q)/2)

### FIXED CODE ###

a,b,x=map(int,input().split())
def water(a,b,x):
  import math
  if math.tan(math.radians(x))<=b/a:
    return (((a**2)*math.tan(math.radians(x))))/2+a*(b-a*math.tan(math.radians(x)))
  else:
    return b**2/(2*math.tan(math.radians(x)))

p=0
q=90
r=0
while r<=1000:
  if water(a,b,(p+q)/2)<=x/a:
    p=p
    q=(p+q)/2
    r=r+1
  else:
    p=(p+q)/2
    q=q
    r=r+1

print((p+q)/2)
### BUGGY CODE ###

n=int(input())
mod = 10**9+7
ans=[1]*12
prime=[2,3,5,7,11,13,17,19,23,27,29,31]
for i in range(1,n+1):
    j=i
    while j>1:
        for k in range(12):
            if j%prime[k]==0:
                ans[k]=(ans[k]+1)%mod
                j=j//prime[k]
A=1
for m in range(12):
    A = (A*ans[m])%mod
print(A)

### FIXED CODE ###

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
n = int(input())
prime = primes(n)
a = [1]*n
for i in range(1,n+1):
    for p in prime:
        while i%p == 0:
            i = i//p
            a[p-1] += 1
ans = 1
for i in a:
    ans *= i
mod = 10**9 + 7
print(ans%mod)
### BUGGY CODE ###

import sys

def isprime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True

for line in sys.stdin:
    n = int(line)
    cnt = 0
    for i in range(1, n + 1):
        if isprime(i):
            cnt += 1
    print cnt

### FIXED CODE ###

max_num = 1000000
cnt = 0
p = [1] * max_num
p[0] = p[1] = 0
for i in xrange(2, int(max_num ** 0.5) + 1):
    if p[i]:
        p[i * i::i] = [0] * len(p[i * i::i])

for i in xrange(max_num):
    cnt += p[i]
    p[i] = cnt

while True:
    try: print(p[int(raw_input())])
    except: break
### BUGGY CODE ###

from collections import Counter
import collections

ket = int(input())
moj = input()
tas = int(input())
x = 0
y = 0
i = 0
j = 0

for i in range(tas):
    que = list(input().split())
    if que[0] == "1":
        x = int(que[1])
        moj = moj[:x-1] + str(que[2]) + moj[x:]
    elif que[0] == "2":
        x = int(que[1])
        y = int(que[2])
        l = list(moj[(x-1):y])
        c = collections.Counter(l)
        i  =c.most_common()
        print(len(i))

### FIXED CODE ###

def main():
    from bisect import bisect_left,bisect
    n = int(input())
    s = list(input())
    q = int(input())
    al=[[] for i in range(26)]
    for i in range(n):
        al[ord(s[i])-97].append(i)
    ans = []
    for i in range(q):
        a , b , x = input().split()
        if a == "1":
            al[ord(s[int(b)-1])-97].pop(bisect_left(al[ord(s[int(b)-1])-97],int(b)-1))
            al[ord(x)-97].insert(bisect_left(al[ord(x)-97],int(b)-1),int(b)-1)
            s[int(b)-1] = x
        elif a == "2":
            b = int(b)-1
            x = int(x)-1
            cou = 0
            for j in range(26):
                l = bisect_left(al[j],b)
                r = bisect(al[j],x)
                if l != r:
                    cou += 1
            ans.append(cou)
    for i in ans:
        print(i)

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

n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7


flg = True
cnt = 0
if n%2 != 0:
    for i in range(n):
        if i==0:
            if lst.count(0) != 1:
                flg = False
        elif i%2!=0 and lst.count(i)!=0:
            flg = False
        elif i%2==0 and lst.count(i)!=2:
            flg = False
        elif i%2==0 and lst.count(i)==2:
            cnt += 1
    ans = 2 ** cnt
    
else:
    for i in range(1,n):
        if i%2==0 and lst.count(i)!=0:
            flg = False
        elif i%2!=0 and lst.count(i)!=2:
            flg = False
        elif i%2!=0 and lst.count(i)==2:
            cnt += 1
    ans = 2 ** cnt

if flg:
    print(ans % mod)
else:
    print(0)

### FIXED CODE ###

from collections import Counter
n = int(input())
lst = [int(i) for i in input().split()]
mod = 10**9 + 7
lst_c = Counter(lst)
lst_c = sorted(lst_c.items(),key = lambda x:x[0])

ideal = []

if n%2!=0:
    ideal.append((0,1))
    for i in range(1,n//2+1):
        ideal.append((2*i,2))
else:
    for i in range(n//2):
        ideal.append((2*i+1,2))

if lst_c != ideal:
    print(0)
else:
    l = len(ideal)
    if n%2!=0:
        l -= 1
    print(2**l % mod)
### BUGGY CODE ###

n = int(input())
dp = [0]*n
cnt = 0
L = []
flag = True
for i in range(n):
  T = []
  N = list(map(int,input().split()))
  for j in range(n-1):
    T.append((i+1,N[j]))
  L.append(T)
while dp != [n-1]*n:
  B = [0]*n
  act = 0
  for i in range(n):
    if B[i] == 0:
      B[i] = 1
      if dp[i] != n-1:
        miru = L[i][dp[i]][1]
        if dp[miru-1] == n-1:
          flag = False
          break
        else:
          if B[miru-1] != 1:
            if L[miru-1][dp[miru-1]][1] == i+1:
              dp[i] += 1
              dp[miru-1] += 1
              B[miru-1] = 1
              act += 1
  if act == 0:
    dp = [n-1]*n
    flag = False
  if cnt >= 300000:
      dp = [n-1]*n
  cnt += 1
if flag == False:
  print(-1)
else:
  print(cnt)

### FIXED CODE ###

import time
start = time.time()
n = int(input())
dp = [0]*n
cnt = 0
L = []
flag = True
for i in range(n):
  T = []
  N = list(map(int,input().split()))
  for j in range(n-1):
    T.append((i+1,N[j]))
  L.append(T)
while dp != [n-1]*n:
  B = [0]*n
  act = 0
  for i in range(n):
    if B[i] == 0:
      B[i] = 1
      if dp[i] != n-1:
        miru = L[i][dp[i]][1]-1
        if dp[miru] == n-1:
          flag = False
          dp = [n-1]*n
        else:
          if B[miru] != 1:
            if L[miru][dp[miru]][1] == i+1:
              dp[i] += 1
              dp[miru] += 1
              B[miru] = 1
              if act == 0:
                act = 1
  if act == 0:
    dp = [n-1]*n
    flag = False
  cnt += 1
  ela = time.time()-start
  if ela > 1.7:
    dp = [n-1]*n
if flag == False:
  print(-1)
else:
  if ela < 1.7:
    print(cnt)
  else:
    print(n*(n-1)//2)
### BUGGY CODE ###

N=int(input())
a=[]
for i in range(N):
  a.append(input())
b=list(set(a))
c=[]
for j in range(len(b)):
  c.append(a.count(b[j]))
d=int(c.count(max(c)))
while True:
  if len(b)==0:
    break
  elif a.count(min(b))==max(c):
    print(min(b))
    b.remove(min(b))
  else:
    b.remove(min(b))

### FIXED CODE ###

N=int(input())
a=[]
for i in range(N):
  a.append(input())
b={}
for j in range(len(a)):
  if a[j] in b:
    b[a[j]]+=1
  else:
    b[a[j]]=1
max_b=max(b.values())
c=[]
for k,l in b.items():
  if l==max_b:
    c.append(k)
c.sort()
for m in c:
  print(m)
### BUGGY CODE ###

N = int(input())
ans = 1

i = []

i = [int(a) for a in input().split()]

for b in range(N):
  ans = ans * i[b]
 
  if ans > 10**18:
    ans = -1
 
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

ans = 1

if 0 in a:
    print("0")
    exit()

for i in a:
    ans *= i

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