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

import itertools

n = int(input())
primes = [x for x in range(3, 55556 * n, 2)]

for i in range(3, 237, 2):
    for j, p in enumerate(primes):
        if p <= i:
            continue
        if p % i == 0:
            primes[j] = 0
primes = [2] + [p for p in primes if p > 0]
aa = [p for p in primes if p <= 55555]
primes = set(primes)

for ps in itertools.combinations(aa, n):
    f = False
    for pps in itertools.combinations(ps, 5):
        if sum(pps) in primes:
            f = True
            break
    if f:
        continue
    print(' '.join(map(str, ps)))
    exit(0)

### FIXED CODE ###

import itertools

n = int(input())
primes = [x for x in range(3, 55556, 2)]

for i in range(3, 237, 2):
    for j, p in enumerate(primes):
        if p <= i:
            continue
        if p % i == 0:
            primes[j] = 0
primes = [2] + [p for p in primes if p > 0]
aa = [p for p in primes if p <= 55555 and p % 5 == 1]
print(' '.join(map(str, aa[:n])))
### BUGGY CODE ###

import sys

def wf(d):
  for i in range(n):
    for j in range(n):#start
      for k in range(n):#end
        d[j][k]=min(d[j][k], d[j][i] + d[i][k])
  return d

n,m,l = map(int, input().split())

d=[[sys.maxsize]*(n) for _ in range(n)]
e=[[sys.maxsize]*(n) for _ in range(n)]
for i in range(n):
  d[i][i] = 0
  e[i][i] = 0

for _ in range(m):
  a,b,c = map(int, input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

d=wf(d)
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      e[i][j] = 1

e=wf(e)

q=int(input())
for _ in range(q):
  s,t = map(int, input().split())
  if e[s-1][t-1] == sys.maxsize:
    print(-1)
  else:
    print(e[s-1][t-1]-1)

### FIXED CODE ###

import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n,m,l = map(int, input().split())

d=[[sys.maxsize]*(n) for _ in range(n)]
e=[[sys.maxsize]*(n) for _ in range(n)]
for i in range(n):
  d[i][i] = 0
  e[i][i] = 0

for _ in range(m):
  a,b,c = map(int, input().split())
  d[a-1][b-1]=c
  d[b-1][a-1]=c

d=floyd_warshall(csr_matrix(d))
for i in range(n):
  for j in range(n):
    if d[i][j] <= l:
      e[i][j] = 1

e=floyd_warshall(csr_matrix(e))

q=int(input())
for _ in range(q):
  s,t = map(int, input().split())
  if e[s-1][t-1] == sys.maxsize:
    print(-1)
  else:
    print(int(e[s-1][t-1]-1))
### BUGGY CODE ###

a = int(input())
b = list(map(int, input().split()))
c = 1
for i in b:
    c *= i
if c > 10**18:
    print('-1')
else:print(c)

### FIXED CODE ###

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

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

mult = 1

for i in a:
    mult *= i
    if mult > 10**18:
        print(-1)
        exit()
print(mult)
### BUGGY CODE ###

import numpy as np
from itertools import permutations
N = int(input())


for n in range(1, N+1):
    count = 0
    for i in range(1, 58):
        if i**2 > n:
            break
        for j in range(i, 58):
            t = (i+j)**2 - 4 * (i * j + i**2 + j**2 - n)
            if t < 0:
                continue
            k = 0.5 * (-(i + j) + np.sqrt(t))
            if k < j:
                break
            if i**2 + j**2 + k**2 + i * j + j * k + i * k > n:
                break
            if int(k) == k:
                count += len(set(permutations([i, j, int(k)])))
    print(count)



### FIXED CODE ###

import numpy as np
from itertools import permutations
N = int(input())

counter = np.zeros(N, dtype=int)

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            res = x**2 + y**2 + z**2 + x * y + x * z + y * z
            if res <= N:  
                counter[res - 1] += 1

for c in counter:
    print(c)
### BUGGY CODE ###

import numpy as np
from collections import deque

xs, ys, xt, yt = map(int, raw_input().split())
N = int(raw_input())
X = [xs]
Y = [ys]
R = [0]
for _ in range(N):
    x, y, r = map(int, raw_input().split())
    X.append(x)
    Y.append(y)
    R.append(r)
X.append(xt)
Y.append(yt)
R.append(0)

X_np = np.array(X)
Y_np = np.array(Y)
R_np = np.array(R)

dist = np.zeros((N+2, N+2))
for i in range(N+2):
    dist[i, :] = np.maximum(np.sqrt((X_np - X_np[i])**2 + (Y_np - Y_np[i])**2) - (R_np + R_np[i]), 0)

cost = 2000000000.0 * np.ones(N+2)
cost[0] = 0
# with minnimum cost
q = 0
unfixed_list = range(N+2)

while len(unfixed_list) > 0:
    new_cost = cost[q] + dist[q, :]
    cost = np.minimum(cost, new_cost)
    q = unfixed_list[cost[unfixed_list].argmin()]
    

print cost[N+1]

### FIXED CODE ###

import numpy as np
from collections import deque

xs, ys, xt, yt = map(int, raw_input().split())
N = int(raw_input())
X = [xs]
Y = [ys]
R = [0]
for _ in range(N):
    x, y, r = map(int, raw_input().split())
    X.append(x)
    Y.append(y)
    R.append(r)
X.append(xt)
Y.append(yt)
R.append(0)

X_np = np.array(X)
Y_np = np.array(Y)
R_np = np.array(R)

dist = np.zeros((N+2, N+2))
for i in range(N+2):
    dist[i, :] = np.maximum(np.sqrt((X_np - X_np[i])**2 + (Y_np - Y_np[i])**2) - (R_np + R_np[i]), 0)

cost = 4000000000.0 * np.ones(N+2)
cost[0] = 0
# with minnimum cost
q = 0
unfixed_list = range(N+2)
unfixed_list.remove(q)


while len(unfixed_list) > 0:
    new_cost = cost[q] + dist[q, :]
    cost = np.minimum(cost, new_cost)
    q = unfixed_list[cost[unfixed_list].argmin()]
    unfixed_list.remove(q)
    

print cost[N+1]
### BUGGY CODE ###

N, K  = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0

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


### FIXED CODE ###

n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])
### BUGGY CODE ###

import heapq
def dijkstra(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * (n+1)
    used = [True] * (n+1) #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in graph_a[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in graph_a[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

def dijkstra1(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * (n+1)
    used = [True] * (n+1) #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in graph_b[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in graph_b[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d


n, m, s, t = map(int, input().split())
# graph作成
graph_a = {i: [] for i in range(1, n + 1)}
graph_b = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v, a, b = map(int, input().split())
    graph_a[u].append([a, v])
    graph_a[v].append([a, u])
    graph_b[u].append([b, v])
    graph_b[v].append([b, u])

yen = dijkstra(s)
snu = dijkstra1(t)

cost = []
for i in range(1, n + 1):
    cost.append([yen[i] + snu[i],i])

cost.sort(key = lambda x: x[0])

nn = -1
l = 0
for i in range(1, n + 1):
    if nn < i:
        for j in range(l, len(cost)):
            if cost[j][1] >= i:
                ss = cost[j][0]
                nn = cost[j][1]
                l = j + 1
                break
    print(10**15-ss)

### FIXED CODE ###

import heapq
INF = 10**18
def dijkstra(s, edge, n):
    d = [INF] * n
    used = [True] * n #True: not used
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d
 
n, m, s, t = map(int, input().split())
s -= 1
t -= 1
graph_a = [[] for _ in range(n)]
graph_b = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    graph_a[u].append((a, v))
    graph_a[v].append((a, u))
    graph_b[u].append((b, v))
    graph_b[v].append((b, u))
 
yen = dijkstra(s, graph_a, n)
snu = dijkstra(t, graph_b, n)

cost = [0] * n
for i in range(n):
    cost[i] = (yen[i] + snu[i],i)

heapq.heapify(cost)
c = -1
aaa = 10 ** 15
for i in range(n):
    if c < i:
        while cost:
            nn, t = heapq.heappop(cost)
            if t >= i:
                c = t
                break
    print(aaa - nn)
### BUGGY CODE ###

MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (1 << N) for _ in range(N+1)]
dp[0][0] = 1
prev = [0]
for i in range(N):
    temp = []
    for j in range(N):
        bit = 1 << j
        for s in prev:
            if A[i][j] == 1 and s & bit == 0:
                new_s = s | bit
                dp[i+1][new_s] += dp[i][s]
                dp[i+1][new_s] %= MOD
                temp.append(new_s)
    prev = list(set(temp))
print(dp[N][(1 << N) - 1])

### FIXED CODE ###

MOD = 10**9 + 7
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
dp = [0] * (1 << N)
dp[0] = 1
bits = [1 << i for i in range(N)]
cands = [[] for _ in range(N+1)]
for s in range(1 << N):
    temp = 0
    for n in range(N):
        if s & (1 << n): temp += 1
    cands[temp].append(s)
for i, a in enumerate(A):
    for j in [k for k, v in enumerate(a) if v == 1]:
        bit = bits[j]
        for s in cands[i]:
            if s & bit == 0:
                new_s = s | bit
                dp[new_s] += dp[s]
                dp[new_s] %= MOD
print(dp[-1])
### BUGGY CODE ###

s = input()
n = len(s)

s='|'+s+'|'

dp=[0]*(n+1)

#数列aの各項a_iについて、左右に連続する'<<<','>>>'の数をそれぞれカウント、
#その最大がa_iの最小値となる
for i in range(n+1):
    max_l=0
    max_r=0
    for l in range(i,-1,-1):
        if s[l]!='<':
            break
        max_l+=1
    for r in range(i+1,n+2):
        if s[r]!='>':
            break
        max_r+=1
    dp[i]=max(max_l,max_r)
#print(dp)
print(sum(dp))



### FIXED CODE ###

s = input()
n = len(s)

s='|'+s+'|'

dp=[0]*(n+1)

#数列aの各項a_iについて、左右に連続する'<<<','>>>'の数をそれぞれカウント、
#その最大がa_iの最小値となる
R = [0]*(n+1)
L = [0]*(n+1)

#left count <<<
for i in range(1,n+1):
    if s[i]=='<':
        L[i] = L[i-1]+1
    else:
        L[i]=0
#right count >>>
for i in range(n-1,-1,-1):
    if s[i+1]=='>':
        R[i] = R[i+1]+1
    else:
        R[i]=0
ans=0
for i in range(n+1):
    ans+=max(R[i],L[i])
#print(L,R,s)
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

q = [0] * N
start = 0
end = 0
for i in range(N):
    q[i] = A[i] * F[i]
    end = max(end, q[i])

def check(now, K):
    cnt = 0
    for i in range(N):
        if q[i] - now > 0:
            cnt += (q[i] - now + F[i] - 1) // F[i]
            if cnt > K:
                return False
    return True

now = end // 2
while end > start + 1:
    if check(now, K):
        end = now
    else:
        start = now
    now = (start + end) // 2

if check(start, K):
    print(start)
else:
    print(end)


### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

q = [0] * N
start = 0
end = 0
for i in range(N):
    q[i] = A[i] * F[i]
    end = max(end, q[i])

def check(now, K):
    cnt = 0
    for i in range(N):
        if q[i] - now > 0:
            cnt += (q[i] - now + F[i] - 1) // F[i]
            if cnt > K:
                return False
    return True

now = end // 2
while end > start + 1:
    if check(now, K):
        end = now
    else:
        start = now
    now = (start + end) // 2

if check(start, K):
    print(start)
else:
    print(end)
### BUGGY CODE ###

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

N, M = map(int, input().split())
edge = np.array([input().split() for _ in range(M)], dtype = np.int64)
edge = sorted(edge,key=lambda x:(x[0],x[1],x[2]))
i = 1
while i < M:
  if edge[i][0] == edge[i-1][0] and edge[i][1] == edge[i-1][1]:
    edge = np.delete(edge,i,0)
  else:
    i += 1
    if i >= len(edge):
      break
x = np.arange(N,1,-1)
y = np.arange(N-1,0,-1)
z = np.zeros(N-1,int)
X = np.vstack([x,y,z]).T
edge = np.concatenate([X,edge]).T
graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
distance_mat = dijkstra(graph, directed = True, indices = 0)
#print(distance_mat)
print(-1 if distance_mat[-1] == float("inf") else int(distance_mat[-1]))

### FIXED CODE ###

import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

N, M = map(int, readline().split())
lines = readlines()
edge = np.array([line.split() for line in lines], dtype = np.int64)
edge = sorted(edge,key=lambda x:(x[0],x[1],x[2]))

for i in range(1,M):
  if edge[i][0] == edge[i-1][0] and edge[i][1] == edge[i-1][1]:
    edge[i][2] = 0
#print(edge)
x = np.arange(N,1,-1)
y = np.arange(N-1,0,-1)
z = np.zeros(N-1,int)
X = np.vstack([x,y,z]).T
edge = np.concatenate([X,edge]).T
graph = csr_matrix((edge[2], (edge[:2] - 1)), (N, N))
distance_mat = dijkstra(graph, directed = True, indices = 0)
#print(distance_mat)
print(-1 if distance_mat[-1] == float("inf") else int(distance_mat[-1]))
### BUGGY CODE ###

X, Y, A, B, C=map(int, input().split())
P=sorted(list(map(int, input().split())), )[-X:]
Q=sorted(list(map(int, input().split())), )[-Y:]
R=sorted(list(map(int, input().split())), reverse=True)

PQ=sorted(P+Q)

ans=0
for i in range(len(PQ)):
  if len(R)>0:
    
    now=max(PQ[i], R.pop(0))
  else:
    now=PQ[i]
  ans+=now
  
print(ans)


### FIXED CODE ###

import numpy as np
X, Y, A, B, C=map(int, input().split())
P=sorted(list(map(int, input().split())), )[-X:]
Q=sorted(list(map(int, input().split())), )[-Y:]
R=sorted(list(map(int, input().split())), reverse=True)

PQ=sorted(P+Q)

ans=0
for i in range(len(PQ)):
  if len(R)>0:
    
    now=max(PQ[i], R.pop(0))
  else:
    now=PQ[i]
  ans+=now
  
print(ans)
### BUGGY CODE ###

import fractions
from functools import reduce
N = int(input())
A=[int(i) for i in input().split()]
B=[]
def list_gcd(a):
    l = len(a)
    if l ==1:
        return(a[0])
    elif l ==2:
        return(fractions.gcd(a[0],a[1]))
    else:
        k = l//2 
        return(fractions.gcd(list_gcd(a[:k]),list_gcd(a[k:])))
b = []
for i in range(N):
    if i>0 and i<N-1:
        a = A[:i]+A[i+1:]
    elif i == 0:
        a = A[1:]
    else:
        a = A[:N-1]
    b.append(list_gcd(a))
print(max(b))

### FIXED CODE ###

import fractions
N = int(input())
A=[int(i) for i in input().split()]
B=[]
L = [0]
R = [0]
for i in range(N):
    L.append(fractions.gcd(A[i],L[i]))
    R.append(fractions.gcd(A[N-i-1],R[i]))
for i in range(N):
    B.append(fractions.gcd(L[i],R[N-i-1]))
print(max(B))
### BUGGY CODE ###

def solve(N, W, weight_values):
    dp = [0 for _ in range(W + 1)]
    for i in range(N):
        wi, vi = weight_values[i]
        for w in range(W, wi - 1, -1):
            dp[w] = max(dp[w], vi + dp[w - wi])
    print(dp[W])

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


N, W = iln()
w_v = []
for i in range(N):
    w_v.append(iln())

solve(N, W, w_v)

### FIXED CODE ###


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0
 
for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))
### BUGGY CODE ###

N, M = map(int, input().split())
dic = {}
raw = []
dic[1] = []
for i in range(M):
  P, Y = map(int, input().split())
  raw.append([P, Y])
  dic.setdefault(P, list())
  dic[P].append(Y)
for i in range(1, N+1):
  try:
    dic[i].sort()
  except:
    continue
for i in range(M):
  P, Y = raw[i]
  ind = dic[P].index(Y)
  P = "{0:06d}".format(P)
  Y = "{0:06d}".format(ind+1)
  print(P+Y)

### FIXED CODE ###

N, M = map(int, input().split())
dic = {}
raw = []
dic[1] = []
for i in range(M):
  P, Y = map(int, input().split())
  raw.append([P, Y, i])
raw.sort()
for i in range(M):
  if i == 0:
    raw[i][1] = 1
    p, y, ind = raw[i]
    continue
  pp, yy, iind = raw[i]
  if pp == p:
    raw[i][1] = y + 1
  else:
    raw[i][1] = 1
  p, y, ind = raw[i]
raw.sort(key = lambda x:x[2])
for r in raw:
    p, y, ind = r
    P = "{0:06d}".format(p)
    Y = "{0:06d}".format(y)
    print(P+Y)
### BUGGY CODE ###

h,w = map(int, input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d=[]
for i in range(h):
    lis=[]
    for j in range(w):
        lis.append(abs(a[i][j]-b[i][j]))
    d.append(lis)

dp = [[[0 for _ in range(80*(h+w))] for _ in range(w)] for _ in range(h)]
dp[0][0][d[0][0]]=1

for i in range(h):
    for j in range(w):
        for k in range(80*(h+w)):
            if dp[i][j][k]==1:
                if j+1<w:
                    nxt=d[i][j+1]
                    dp[i][j+1][k+nxt] = 1
                    dp[i][j+1][abs(k-nxt)] = 1
                if i+1<h:
                    nxt=d[i+1][j]
                    dp[i+1][j][k+nxt] = 1
                    dp[i+1][j][abs(k-nxt)] = 1


for ind in range(len(dp[h-1][w-1])):
    if dp[h-1][w-1][ind]==1:
        print(ind)
        exit()

### FIXED CODE ###

h,w = map(int, input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        d[i][j] = abs(a[i][j]-b[i][j])

dp = [[0 for _ in range(6400)] for _ in range(h*w)]
dp[0][d[0][0]]=1

for i in range(h*w):
    nowh,noww = divmod(i,w)
    for k in range(6400):
        if not dp[nowh*w + noww][k]==1:
            continue
        nxth,nxtw=nowh+1, noww+1
        if nxtw<w:
            if k+d[nowh][nxtw] < 6400:
                dp[nowh*w + nxtw][k+d[nowh][nxtw]] = 1
            dp[nowh*w + nxtw][abs(k-d[nowh][nxtw])] = 1
        if nxth<h:
            if k+ d[nxth][noww]< 6400:
                dp[nxth*w + noww][k+d[nxth][noww]] = 1
            dp[nxth*w + noww][abs(k-d[nxth][noww])] = 1


for k in range(6400):
    if dp[-1][k]==1:
        print(k)
        exit()
### BUGGY CODE ###

n, = (int(x) for x in input().split())
p = list(int(x) for x in input().split())

x = 0
for i in range(n):
    if p[i] <= min(p[:i]+[p[i]]):
        x += 1
        pass
print(x)

### FIXED CODE ###

n, = (int(x) for x in input().split())
p = list(int(x) for x in input().split())
 
x = 0
m = 1e6
for i in range(n):
    if p[i] <= m:
        x += 1
        m = p[i]
print(x)
### BUGGY CODE ###

k = int(input())
if k % 2 == 0:
    print(-1)
    exit()
elif k == 1 or k == 7:
    print(1)
    exit()
sv = 7
ans = 1
while True:
    if sv == 0:
        break
    sv = (sv * 10 + 7) % k
    ans += 1
print(ans)

### FIXED CODE ###

k = int(input())
sv = 7
for i in range(1, 10**6 + 1):
    if sv % k == 0:
        print(i)
        exit()
    sv = (sv * 10 + 7) % k
print(-1)
### BUGGY CODE ###

n=input()
s=''
for i in range(n):
	s+=raw_input()
s+=s
result=0
for shift in range(n):
	ok=True
	for i in range(n):
		for j in range(n):
			if s[(i+shift)*n+j]!=s[(j+shift)*n+i]:
				ok=False
				break
	if ok:
		result+=n
print result

### FIXED CODE ###

n=input()
s=[raw_input() for i in range(n)]
t=[]
for i in range(n):
	t+=[s[j][i] for j in xrange(n)]*2
s+=s
s=''.join(s)
#print s
t=''.join(t)
#print t
result=0
for shift in xrange(n):
	ok=True
	for i in xrange(n):
		if s[(i+shift)*n: (i+shift)*n+n]!=t[i*n*2+shift: i*n*2+shift+n]:
			ok=False
			break
	if ok:
		result+=n
print result
### BUGGY CODE ###

n = int(input())
a = input().split(" ")
lista = [int(n) for n in a]
kotae=1
for i in range(n):
  kotae=kotae*lista[i]
if kotae>10**18:
  print(-1)
else:
  print(kotae)

### FIXED CODE ###

n = int(input())
a = input().split(" ")
kotae=1
listaa = [int(n) for n in a]
lista = sorted(listaa)
if lista[0]==0:
  print(0)
  exit()
for i in range(n):
  kotae*=lista[i]
  if kotae>10**18:
    kotae=-1
    break
if kotae>10**18:
  kotae=-1
print(kotae)
### BUGGY CODE ###

k = int(input())
ans = 0
now = 7
while True:
    now = now % k
    if now == 0:
        print(ans+1)
        break
    else:
        ans += 1
        if now*10 + 7 % k == 0:
            print(-1)
            break
        else:
            now = now*10 + 7


### FIXED CODE ###

k = int(input())
ans = 0
now = 7
if k == 1 or k == 7:
    now = 0
while True:
    if ans > k:
        print(-1)
        break
    elif now == 0:
        print(ans+1)
        break
    else:
        now = (now*10 + 7) % k
        ans += 1
### BUGGY CODE ###

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

def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    l = [0] * N
    ans = 0
    count = 0
    check = [False] * N
    tmpl = []
    next = False

    while(count < N):
        check = [False] * N
        for i in range(N):
            if l[i] < N - 1:
                to = A[i][l[i]] - 1
                if (not check[to]) and (not check[i]):
                    if A[to][l[to]] - 1 == i:
                        l[i] += 1
                        l[to] += 1
                        check[to] = True
                        check[i] = True
                        next = True
                    if l[i] == N - 1:
                        count += 1
                    if l[to] == N - 1:
                        count += 1
        ans += 1
        if not next:
            print(-1)
            exit()
        next = False
        # print(l, ans)

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import time
def input():
    return sys.stdin.readline()
 
def main():
    a = time.time()
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    l = [0] * N
    ans = 0
    count = 0
    check = [False] * N
    tmpl = []
    next = False
 
    while(count < N):
        check = [False] * N
        for i in range(N):
            if l[i] < N - 1:
                to = A[i][l[i]] - 1
                if (not check[to]) and (not check[i]):
                    if A[to][l[to]] - 1 == i:
                        l[i] += 1
                        l[to] += 1
                        check[to] = True
                        check[i] = True
                        next = True
                    if l[i] == N - 1:
                        count += 1
                    if l[to] == N - 1:
                        count += 1
        ans += 1
        if not next:
            print(-1)
            exit()
        next = False

        b = time.time()
        if b - a >= 1.7:
            print(N*(N - 1)//2)
            exit()
        # print(l, ans)
 
    print(ans)
 
if __name__ == '__main__':
    main()