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

n = int(input())
a = input().split()
a_int = [int(n) for n in a]
ans = 1
if 0 in a_int:
    print(0)
else:
 for num in a_int:
     ans *= num
 if ans > 10**18:
     print(-1)
 else:
     print(ans)

### FIXED CODE ###

N = int(input())
A = map(int, input().split())
 
res = 1
 
for a in sorted(A):
    res *= a
    if res > 10 ** 18:
        print("-1")
        exit()
print(res)
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
l = [list(map(int,input().split())) for i in range(q)]
ans = []
for i in range(q):
    ans.append(s[l[i][0]-1:l[i][1]].count('AC'))
for i in range(q):
    print(ans[i])


### FIXED CODE ###

n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=="AC" else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

import math

N, K = [int(x) for x in input().split()]
As = sorted([int(x) for x in input().split()])
Fs = sorted([int(x) for x in input().split()], reverse=True)

def in_n_sec(n):
  total_training = sum(max(0, a-int(n/f)) for a, f in zip(As, Fs))
  return total_training <= K
  
current_worst_confirmed = 10**12
current_best_possible = 0
while current_worst_confirmed > current_best_possible:
  to_try = (current_worst_confirmed + current_best_possible ) // 2
  if in_n_sec(to_try):
    current_worst_confirmed = to_try
  else:
    current_best_possible = to_try + 1
print(current_worst_confirmed)
    
  


### FIXED CODE ###

import math

N, K = [int(x) for x in input().split()]
As = sorted([int(x) for x in input().split()])
Fs = sorted([int(x) for x in input().split()], reverse=True)

def in_n_sec(n):
  total_training = sum(max(0, a-int(n/f)) for a, f in zip(As, Fs))
  return total_training <= K
  
current_worst_confirmed = 10**12
current_best_possible = 0
while current_worst_confirmed > current_best_possible:
  to_try = (current_worst_confirmed + current_best_possible ) // 2
  if in_n_sec(to_try):
    current_worst_confirmed = to_try
  else:
    current_best_possible = to_try + 1
print(current_worst_confirmed)
### BUGGY CODE ###

N,M = map(int,input().split())
import time
start_t = time.time()
path = [[] for _ in range(N*3+3)]
for _ in range(M):
    u,v = map(int,input().split())
    path[u].append(v+N)
    path[u+N].append(v+N+N)
    path[u+N+N].append(v)

S,T = map(int,input().split())
import collections

q = collections.deque()
vis = [-1 for _ in range(N*3+3)]
def bfs():
    while len(q) > 0:
        if time.time() -start_t > 1.99:
            return -3
        now,cnt = q.popleft()
        #print(now,T,cnt,path[now],q)
        vis[now] = cnt
        if now == T: 
            return cnt
        [q.append((x,cnt+1)) for x in path[now] if vis[x] == -1]
        #for x in path[now]:
         #   if vis[x] == -1:
          #      q.append((x,cnt+1))
    return -3
vis[S] = 1
q.append([S,0])
print(bfs()//3)




### FIXED CODE ###

N,M = map(int,input().split())
import time
start_t = time.time()
path = [[] for _ in range(N+3)]
for _ in range(M):
    u,v = map(int,input().split())
    path[u].append(v)

S,T = map(int,input().split())
import collections

q = collections.deque()
vis = [[-1 for _ in range(3)] for _ in range(N+3)]
vis[S][0] = 1
q.append([S,0])
while len(q):
    now,cnt = q.popleft()
    step = cnt % 3
    for x in path[now]:
        if vis[x][(step+1)%3] < 0:
            vis[x][(step+1)%3] = cnt
            q.append((x,cnt+1))

if vis[T][0] == -1:
    print(-1)
else:
    print(vis[T][0]//3+1)
### BUGGY CODE ###

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

p = int(P**(1/N)) + 1
n = 0
for i in range(1,p+1):
    if P % (i**N) == 0:
        n = i
print(n)

### FIXED CODE ###

N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP):
    for i in range(2,lim+1):
        while newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP = newP // i
        if newP < i or i == lim:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
my(N,P)
### BUGGY CODE ###

def main():
    n = int(input())
    count = 0
    lists =[]
    count_dict = {}

    for i in range(n):
        input_data = ''.join(sorted(input()))
        if input_data in lists:
            if input_data not in count_dict.keys():
                count_dict[input_data] = 1
            count += count_dict[input_data]
            count_dict[input_data] += 1
        else:
            lists.append(input_data)

    print(count)


if __name__ == '__main__' :
    main()

### FIXED CODE ###

from collections import Counter

n = int(input())
count = 0
lists =[]
count_dict = Counter()

for i in range(n):
    input_data = ''.join(sorted(input()))
    if input_data in count_dict:
        count += count_dict[input_data]
        count_dict[input_data] += 1
    else:
        count_dict[input_data] = 1

print(count)
### BUGGY CODE ###

n,h=map(int,input().split())
l=list(map(int,input().split()))
c=[10**9]*n
c[0]=0
c[1]=abs(l[0]-l[1])
for i in range(2,n):
    c[i]=min( c[i-j]+abs(l[i]-l[i-j]) for j in range(1,h+1) if i-j > -1 )
print(c[-1])

### FIXED CODE ###

n,h=map(int,input().split())
l=list(map(int,input().split()))
c=[10**9]*n
c[0]=0
c[1]=abs(l[0]-l[1])
for i in range(2,n):
    c[i]=min( c[j]+abs(l[i]-l[j]) for j in range(max(0,i-h),i) )
print(c[-1])
### BUGGY CODE ###

import numpy as np

N, M = map(int,input().split())
A = list(map(int,input().split()))
bc = []
for _ in range(M):
  A.sort()
  bc = list(map(int,input().split()))
  n = sum(a < bc[1] for a in A)
  if n >= bc[0]:
    for i in range(bc[0]):
      A[i] = bc[1]
  else:
    for i in range(n):
      A[i] = bc[1]
print(sum(A))
  
  

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))
### BUGGY CODE ###

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

#aru index wo nanko no denkyuu ga terashiteiruka
def imos(n,a,ban):
  imos_l=[0 for i in range(n)]
#  imos_l=a

  for i in range(n):
    x=i
    x_left=max(x-a[i],0)
    x_right=min(x+a[i],n-1)

    imos_l[x_left]+=1 #適宜加算する値に変える
    if (x_right+1)!=n:
      imos_l[x_right+1]-=1 #適宜加算する値に変える

    #シミュレート(累積和)
  b=[0]
  for i in range(1,n+1):
    b.append(imos_l[i-1]+b[i-1])

#    if i>ban+1:
#      break

#  return(b[1:],b[ban+1])
#  return(b[ban+1])
  return(b[1:])

#ans,t_ans=imos(n,a,0)
#ans=a
#ans=imos(n,a,0)
#print(ans)

for i in range(k):
#  b,bi=imos(n,a,i)
  b=imos(n,a,i)
#  print(b)
#  print(b)
#  a[i]=b
  a=b
#  ans.append(bi)

#  exit()
##print('\n')
#print(6)
print(*a)
#print(ans)

### FIXED CODE ###

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

def imos(n,a):
  imos_l=[0 for i in range(n)]

  for i in range(n):
    x=i
    x_left=max(x-a[i],0)
    x_right=min(x+a[i],n-1)

    imos_l[x_left]+=1
    if (x_right+1)!=n:
      imos_l[x_right+1]-=1

  b=[0]
  for i in range(1,n+1):
    b.append(imos_l[i-1]+b[i-1])

  return(b[1:])

for i in range(k):
  a=imos(n,a)

  if a.count(n)==n:
    break

print(*a)
### BUGGY CODE ###

N = int(input())
mlist = list(map(int, input().split()))

s = 1
for i in mlist:
    s *= int(i)

if s > 1000000000000000000:
    print(-1)
else:
    print(s)

### FIXED CODE ###

N = int(input())
mlist = list(map(int,input().split()))

s = 1
for i in range(N):
    if mlist[i] == 0:
        print(0)
        s = 0
        break
    elif s > 0:
        s *= mlist[i]

    if s > 10 ** 18:
        s = -1
if i == N-1 and s != 0:
    print(s)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
ans=[]
for i in range(k):
    s *= a[i]
ans.append(s)
for i in range(k, n):
    s = s * a[i] // a[i - k]
    ans.append(s)
    # print(ans)

for i in range(1, n - k + 1):
    if ans[i - 1] < ans[i]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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


a,b,n=map(int,input().split())
i=0
while True:
    if b*i<=n:
        i+=1
    else:
        break
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))

### FIXED CODE ###


a,b,n=map(int,input().split())
i=(n//b)*b
r=(a*n)//b-a*(n//b)
if i>1:
    x=b*(i+1)-1
    r1=(a*x)//b-a*(x//b)
else:
    r1=0
print(max(r,r1))
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 
N = int(input())
A = LI()
A.sort()
 
cc = collections.Counter(A)
# print(cc)
chosen = []
cnt = 0
for key in cc.keys():
    if cc[key] > 1:
        chosen.append(key)
        continue
    if len(chosen) == 0:
        cnt += 1
        chosen.append(key)
    else:
        for c in chosen:
            if key % c == 0:
                break
        else:
            chosen.append(key)
            cnt += 1
 
print(cnt)

### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 

"""
3
1 1 2
のパターンが例外だった
"""

N = int(input())
A = LI()
A.sort()

table = [0 for i in range(10 ** 6 + 1)]
cnt = 0

cc = collections.Counter(A)
duplicate = []
for key in cc.keys():
    if cc[key] > 1:
        duplicate.append(key)

for a in A:
    if table[a] != 0:
        pass
    else:
        if a not in duplicate:
            cnt += 1
        for i in range(1, 10 ** 6 + 1):
            if a * i > 10 ** 6:
                break
            table[a * i] = 1

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

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

def count(n, r):
    ue = 1
    sita = 1
    for i in range(r):
        ue *= (n-i)
        sita *= (r-i)
    return ue // sita

answer = 2**n
answer -= count(n, a)
answer -= count(n, b)
answer -= 1
        
answer %= (10**9+7)
print(answer)

### FIXED CODE ###

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

def kurikaeshi(x, n, mod):
    if n == 1:
        return x%mod
    elif n %2 == 0:
        return kurikaeshi(x, n//2, mod)**2%mod
    elif n %2 == 1:
        return kurikaeshi(x, n//2, mod)**2*x%mod
    
    
def combination(n, a, mod):
    bunbo = 1
    bunshi = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
        
    return bunshi*pow(bunbo, mod-2, mod)%mod
        
        
mod = 1000000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)
### BUGGY CODE ###

N,X=map(int,input().split())
def humberger(N):
    if N==0:
        return [1]
    else:
        return [0]+humberger(N-1)+[1]+humberger(N-1)+[0]
list1=humberger(N)
del list1[X:]
print(sum(list1))

### FIXED CODE ###

N, X = map(int, input().split())
a,p=[1],[1] 
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def f(N,X): #X<=0やX>a_Nを許容し解説本文から簡略化
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))
### BUGGY CODE ###

s=input()
t=list(map(int,input().split()))
a=int(s)
pp=[]
for i in range(a):
  for j in range(a):
    if t[j]==i+1:
      pp.append(j+1)
      break
print(*pp)

### FIXED CODE ###

s=input()
t=list(map(int,input().split()))
a=int(s)
pp=[0 for i in range(a)]
for i in range(a):
  pp[t[i]-1]=i+1
print(*pp)
### BUGGY CODE ###


def Calculate_inconveniece(group):
    if len(group) == 1:
        return 0
    else:
        Mysum = 0
        group_count = len(group)
        for i in range(group_count):
            num_group1 = len(group[i])
            for j in range(i + 1, group_count):
                Mysum += num_group1 * len(group[j])
        return Mysum


def Conect_island(index, group):
    right = index[0]
    left = index[1]
    right_index = [i for i in range(len(group)) if right in group[i]][0]
    left_index = [i for i in range(len(group)) if left in group[i]][0]
    if right_index == left_index:
        return group
    else:
        temp = group[right_index]
        group[left_index] += temp
        del(group[right_index])
        return group



n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
group = [[i]for i in range(1, n+1)]
ans =[]
for idnex in range(1, len(a) + 1):
    # print(Calculate_inconveniece(group))
    ans.append(Calculate_inconveniece(group))
    x = a[-idnex]
    group = Conect_island(x, group)
    # print(x)

for i in range(1, len(a) + 1):
    print(ans[-i])

### FIXED CODE ###

class UnionFind:
    Parents = None

    def __init__(self, N):
        self.Parents = [-1 for i in range(N + 1)]

    # Aがどのグループにいるのか調べる
    def root(self, A):
        if self.Parents[A] < 0:
            return A
        else:
            self.Parents[A] = self.root(self.Parents[A])
            return self.Parents[A]

    # Aが所属しているグループのサイズを返す
    def size(self, A):
        return -self.Parents[self.root(A)]

    # AとBをくっつける
    def Connect(self, A, B):
        if self.root(A) == self.root(B):
            return False
        if self.size(A) < self.size(B):
            self.Parents[self.root(B)] += self.Parents[self.root(A)]
            self.Parents[self.root(A)] = B
        else:
            self.Parents[self.root(A)] += self.Parents[self.root(B)]
            self.Parents[self.root(B)] = A
        return True


n, m = map(int, input().split())
a = [input().split() for i in range(m)]
a = [(int(i[0]), int(i[1])) for i in a]
ans = [int(n * (n - 1) / 2) for i in range(m)]
uni = UnionFind(n)

for i in range(m):
    if i == 0:
        continue
    A = a[-i][0]
    B = a[-i][1]

    if uni.root(A) != uni.root(B):
        ans[i] = ans[i-1] - uni.size(A) * uni.size(B)
        uni.Connect(A, B)
    else:
        ans[i] = ans[i-1]


for i in range(1, m+1):
    print(ans[-i])
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

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

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

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

numlist = list(numset)
for i in range(2,N+1):
    for j in numlist:
        if j >= i:
            break
        dp[i] += dp[i-j]
    
print(dp[N] % 998244353)

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

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

L = []
for i in range(K):
    l, r = map(int, input().split())
    L.append((l,r))

L.sort()

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

for i in range(2,N+1):
    count = 0
    for l,r in L:
        if l >= i:
            break
        elif l < i and i - r > 1:
            count += dp[i-l] - dp[i-r-1]
        else:
            count += dp[i-l]
    dp[i] = (dp[i-1] + count) % mod

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

s = input()
c = 0
for i in range(len(s)):
    for j in range(i+4,len(s)+1):
        a = int(s[i:j])
        if a>=2019:
            if a%3==0:
                if a%673==0:
                    c += 1
print(c)

### FIXED CODE ###

s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
n,a,b = map(int, input().split())
h=[int(input()) for i in range(n)]

def solve(num,hit):
    all_b = num*b
    cnt=0
    for i in range(len(hit)):
        rest = hit[i] - all_b
        if rest>0:
            cnt+=(rest - 1) // (a-b) + 1
    if cnt <= num:
        return True
    else:
        return False

import copy
l=0
r=10**10
while r-l>1:
    hit = copy.deepcopy(h)
    mid=(l+r)//2

    if solve(mid,hit):
        r=mid
    else:
        l=mid
print(r)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,a,b = map(int, input().split())
h=[int(input()) for i in range(n)]

def solve(num):
    all_b = num*b
    cnt=0
    for i in range(len(h)):
        rest = h[i] - all_b
        if rest>0:
            cnt+=(rest - 1) // (a-b) + 1
    if cnt <= num:
        return True
    else:
        return False

import copy
l=0
r=10**10
while r-l>1:
    mid=(l+r)//2

    if solve(mid):
        r=mid
    else:
        l=mid
print(r)
### BUGGY CODE ###

import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
p = [True for _ in range(10 ** 6 + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count

### FIXED CODE ###

import collections
n = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
cc = collections.Counter(ais)
ais.sort()
m = max(ais)
p = [True for _ in range(m + 1)]

count = 0
for ai in ais:
	if p[ai] is True:
		x = 2 * ai
	 	while(x < len(p)): 
	 		p[x] = False
	 		x += ai
for ai in ais:
	if p[ai] is True:
		if cc[ai] == 1:
			count +=1
print count
### BUGGY CODE ###


import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, input().split()))

    MOD = 10**9+7

    from collections import Counter

    def prime(n):
        p = Counter()

        while not n % 2:
            p[2] += 1
            n //= 2
            
        i = 3
        
        while i <= n**0.5:
            while not n % i:
                p[i] += 1
                n //= i
            i += 2
            
        if n > 1: p[n] += 1
        
        return p

    c = Counter()
    for a in A:
        p = prime(a)

        for key, value in p.items():
            c[key] = max(c[key], value)

    n = 1
    for key, value in c.items():
        n *= key**value

    ans = 0
    for a in A:
        ans += n * pow(a, MOD-2, MOD) 
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    main()
    


### FIXED CODE ###

import sys
input = sys.stdin.readline

MOD = 10**9+7
def pow(a, b):
    res = 1
    while b:
        if b & 1: res = res * a % MOD
        a = a**2 % MOD
        b >>= 1
    return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = set(A)
    
    m = max(B)+1    
    prime = {i:i for i in range(m)}
    is_prime = [False] * m
    
    for i in range(2, int(m**0.5)+1):
        if is_prime[i]: continue
        is_prime[i] = True
        
        for j in range(2*i, m, i):
            if not is_prime[j]: prime[j] = i
            is_prime[j] = True
            
    from collections import Counter
    
    count = Counter()
            
    for a in A:
        c = Counter()
        while a > 1:
            n = prime[a]
            c[n] += 1
            a //= n
        for k, v in c.items(): count[k] = max(count[k], v)
            
    x = 1
    for k, v in count.items(): x = x * k**v % MOD
    
    ans = 0
    for a in A: ans += x * pow(a, MOD-2) % MOD
    
    print(ans%MOD)

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

from itertools import combinations

n, s = map(int, input().split())
a = list(map(int, input().split()))
selections = []
for i in range(1, n + 1):
    for selection in combinations(range(n), i):
        if sum([a[j] for j in selection]) == s:
            selections.append(list(selection))

ans = 0
for selection in selections:
    ans += (selection[0] + 1) * (n - selection[-1])
print(ans % 998244353)

### FIXED CODE ###

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

dp = [[0] * (s + 1) for _ in range(n + 1)]
ans = 0
for i in range(n):
    dp[i][0] += 1
    for j in range(s + 1):
        dp[i + 1][j] += dp[i][j]
        dp[i + 1][j] %= MOD
        if j + a[i] <= s:
            dp[i + 1][j + a[i]] += dp[i][j]
            dp[i + 1][j + a[i]] %= MOD
    ans += dp[i + 1][s]
    ans %= MOD

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

import os
import sys

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
S, T = list(map(int, sys.stdin.readline().split()))

U = []
V = []
for u, v in UV:
    U.extend([u, u + N, u + N * 2])
    V.extend([v + N, v + N * 2, v])

graph = csr_matrix(([1] * (M * 3), (U, V)), shape=(N * 3 + 1, N * 3 + 1))
dist = dijkstra(graph, indices=S)[T]
if dist < np.inf:
    print(int(dist // 3))
else:
    print(-1)


### FIXED CODE ###

import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N, M = list(map(int, sys.stdin.readline().split()))
UV = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
S, T = list(map(int, sys.stdin.readline().split()))

graph = [[] for _ in range(N + 1)]
for u, v in UV:
    graph[u].append(v)

que = deque()
que.append((S, 0))
reached = np.zeros((N + 1, 3), dtype=bool)
reached[S, 0] = True

while que:
    u, step = que.popleft()
    for v in graph[u]:
        s = step + 1
        if not reached[v, s % 3]:
            reached[v, s % 3] = True
            que.append((v, s))
        if v == T and s % 3 == 0:
            print(s // 3)
            exit()
print(-1)
### BUGGY CODE ###

N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)
    
l_sorted=sorted(l)

lst = sorted(set(l))
n_list = []

for x in lst:
    n = l_sorted.count(x)
    n_list.append(n)

max_n = max(n_list)
l_max = [i for i, x in enumerate(n_list) if x == max_n]

for x in l_max:
    print(lst[x])

### FIXED CODE ###

import collections

N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)

l_dict = collections.Counter(l)

max_n = max(l_dict.values())

l_max = sorted([x[0] for x in l_dict.items() if x[1] == max_n])

for a in l_max:
    print(a)