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

from collections import deque
n = int(input())
a = []
for i in range(n):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [[[] for i in range(n)] for i in range(n)]
c = 0
day = 0
for i in range(n):
    ap = [i,a[i][0]-1]
    ap.sort()
    for j in range(1,n-1):
        p = [i,a[i][j]-1]
        p.sort()
        l[ap[0]][ap[1]].append(p)
        ap = p
rl = [[0 for i in range(n)] for i in range(n)]
d = deque()
for i in range(n):
    for j in range(n):
        if i < j:
            if len(l[i][j]) > 0:
                for k in l[i][j]:
                    rl[k[0]][k[1]] = 1
#print(rl)
for i in range(n):
    for j in range(n):
        if i < j:
            if rl[i][j] == 0:
                d.append([[i,j],0])
rl=[[0 for i in range(n)] for i in range(n)]
al = []
key = 0
#print(l)
if len(d) == 0:
    key = 1
while len(d):
    now,day = d.pop()
    if rl[now[0]][now[1]] == 0:
        rl[now[0]][now[1]] = 1
    else:
        key = 1
        break
    day += 1
    if len(l[now[0]][now[1]]) == 0:
        al.append(day)
        rl = [[0 for i in range(n)] for i in range(n)]
    else:
        for i in l[now[0]][now[1]]:
            d.append([i,day])
if key == 1:
    print(-1)
else:
    print(max(al))

### FIXED CODE ###

from collections import deque
n = int(input())
a = []
for i in range(n):
    a1 = list(map(int,input().split()))
    a.append(a1)
l = [[[] for i in range(n)] for i in range(n)]
c = 0
day = 0
for i in range(n):
    ap = [i,a[i][0]-1]
    ap.sort()
    for j in range(1,n-1):
        p = [i,a[i][j]-1]
        p.sort()
        l[ap[0]][ap[1]].append(p)
        ap = p
rl = [[0 for i in range(n)] for i in range(n)]
dl = [[0 for i in range(n)] for i in range(n)]
d = deque()
for i in range(n):
    for j in range(n):
        if i < j:
            if len(l[i][j]) > 0:
                for k in l[i][j]:
                    rl[k[0]][k[1]] += 1
#print(rl)
for i in range(n):
    for j in range(n):
        if i < j:
            if rl[i][j] == 0:
                d.append([[i,j],0])
al = []
key = 0
#print(l)
if len(d) == 0:
    key = 1
while len(d):
    #print(d)
    now,day = d.pop()
    day += 1
    if len(l[now[0]][now[1]]) == 0:
        al.append(day)
    else:
        for i in l[now[0]][now[1]]:
            if rl[i[0]][i[1]] == 1:
                rl[i[0]][i[1]] -= 1
                d.append([i,max(day,dl[i[0]][i[1]])])
            else:
                rl[i[0]][i[1]] -= 1
                dl[i[0]][i[1]] = max(day,dl[i[0]][i[1]])
    if day > n*(n-1)//2:
        key = 1
        break
md = 0
for i in range(n):
    md += sum(rl[i])
if key == 1 or md > 0:
    print(-1)
else:
    print(max(al))
### BUGGY CODE ###

import sys

def exhaustiveSearch(A, m):
    if len(A) == 1 and A[0] != m or m < 0:
        return False
    elif A[0] == m:
        return True
    return exhaustiveSearch(A[1:], m) or exhaustiveSearch(A[1:], m - A[0])

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    A = map(int, lines[1].split())
    M = map(int, lines[3].split())

    for m in M:
        if exhaustiveSearch(A, m):
            print "yes"
        else:
            print "no"

### FIXED CODE ###

import sys

def exhaustiveSearch(A, m, i, s):
    if A[i] == m:
        return True
    elif i == len(A) - 1 or m < 0 or m > s:
        return False

    return exhaustiveSearch(A, m, i + 1, s) or exhaustiveSearch(A, m - A[i], i + 1, s)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    A = map(int, lines[1].split())
    M = map(int, lines[3].split())
    s = sum(A)

    for m in M:
        if exhaustiveSearch(A, m, 0, s):
            print "yes"
        else:
            print "no"
### BUGGY CODE ###

N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
ans = 0
A = []
B = 0
for i in range(len(p)-K+1):
    P = p[i:i+K]
    if ans < sum(P):
        ans2 = P
    ans = max(ans,sum(ans2))
for j in range(len(ans2)):
    for k in range(1,ans2[j]+1):
        A.append(k)
    B += sum(A)/ans2[j]
    A.clear()
print(B)

### FIXED CODE ###

from itertools import accumulate
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
for i in range(N):
    P[i] = 1+(P[i]-1)/2
ruiseki = list(accumulate([0]+P))
ans = 0
for i in range(N-K+1):
    ans = max(ans,ruiseki[i+K]-ruiseki[i])
print(ans)
### BUGGY CODE ###

def calc_factorial(n):
    if n == 0:
        return 1
    else:
        num = 1
        for i in range(2, n+1):
            num = num * i
        return num


def calc_comb(n, k, fact_N):
    if 0 in [n, k, n-k]:
        return 1
    else:
        return int(fact_N/(calc_factorial(k)*calc_factorial(N-k)))


N, A, B, K = map(int, input().split(" "))

count = 0
num_A = 0
max_A = int(K / A)
fact_N = calc_factorial(N)

for num_A in range(N):
    left_beauty = K - num_A * A
    if left_beauty < 0:
        break
    # print("left_b: {}".format(left_beauty))

    if left_beauty % B == 0:
        # print("OK")
        num_B = int(left_beauty / B)

        comb_A = calc_comb(N, num_A, fact_N)
        comb_B = calc_comb(N, num_B, fact_N)
        count += comb_A * comb_B

        # print("comb_A: {}, comb_B: {}, count: {}".format(comb_A, comb_B, count))

print(count % 998244353)


### FIXED CODE ###

N, A, B, K = map(int, input().split(" "))
mod = 998244353
ncr = [1] * (N + 1)
v = 1

for i in range(N):
    v = (v * ((N - i) % mod) * pow((i + 1), mod - 2, mod)) % mod
    ncr[i + 1] = v % mod

pat = 0
for a in range(N + 1):
    if (K - (a * A) < 0):
        break
    if (K - (a * A)) % B == 0 and ((K - (a * A)) // B) <= N:
        pat += ncr[a] * ncr[(K - (a * A)) // B]
        pat %= mod

print(pat % mod)
### BUGGY CODE ###

h, w = map(int, input().split())
As = [list(input()) for i in range(h)]

x,y = 0,0

ans = "Possible"

while True:
    cnt = 0
    
    # 上か左が"#" -> error
    if (x > 0 and As[y][x-1] == "#") or (y > 0 and As[y-1][x] == "#"):
        ans = "Impossible"
        break
    
    # 右も下も"#" -> error
    if x < w - 1 and As[y][x+1] == "#" and y < h - 1 and As[y+1][x] == "#":
        ans = "Impossible"
        break
    
    # 右に移動
    if x < w - 1 and As[y][x+1] == "#":
        As[y][x] = "."
        x += 1
    # 左に移動
    if y < h - 1 and As[y+1][x] == "#":
        As[y][x] = "."
        y += 1
        
    # 右下に到着
    if x == w - 1 and y == h - 1:
        As[y][x] = "."
        break

for A in As:
    if "#" in A:
        ans = "Impossible"

print(ans)

### FIXED CODE ###

h, w = map(int, input().split())
As = [list(input()) for i in range(h)]

x,y = 0,0

ans = "Possible"

while True:
    cnt = 0
    tmpX,tmpY = x,y
    # 上か左が"#" -> error
    if (x > 0 and As[y][x-1] == "#") or (y > 0 and As[y-1][x] == "#"):
        ans = "Impossible"
        break
    
    # 右も下も"#" -> error
    if x < w - 1 and As[y][x+1] == "#" and y < h - 1 and As[y+1][x] == "#":
        ans = "Impossible"
        break
    
    # 右に移動
    if x < w - 1 and As[y][x+1] == "#":
        As[y][x] = "."
        x += 1
    # 左に移動
    if y < h - 1 and As[y+1][x] == "#":
        As[y][x] = "."
        y += 1
        
    # 右下に到着
    if x == w - 1 and y == h - 1:
        As[y][x] = "."
        break

    # 移動していない
    if x == tmpX and y == tmpY:
        ans = "Impossible"
        break
        
for A in As:
    if "#" in A:
        ans = "Impossible"

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

def main():
    N, D, A = map(int, input().split())
    XH = []
    for i in range(N):
        x, h = map(int, input().split())
        h = (h + (A - 1)) // A
        XH.append([x, h])

    XH.sort()
    result = 0
    for i in range(N):
        x, h = XH[i]
        if h < 0:
            continue
        result += h
        for j in range(i + 1, N):
            if XH[j][0] > x + 2 * D:
                break
            XH[j][1] -= h
    print(result)
main()


### FIXED CODE ###

N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]

XH.sort()
q = []
t = 0
result = 0
for x, h in XH:
    while True:
        if len(q) == 0:
            break
        if x <= q[0][0]:
            break
        t -= q[0][1]
        q.pop(0)
    h -= t
    if h < 0:
        continue
    c = (h + A - 1) // A
    result += c
    t += c * A
    q.append((x + 2 * D, c * A))
print(result)
### BUGGY CODE ###

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

max_gcd = 0
for i in range(N):
  temp_A = A[:i] + A[i+1:]
  temp_gcd = temp_A[0]
  for j in range(N-1):
    temp_gcd = gcd(temp_gcd,temp_A[j])

  if temp_gcd > max_gcd:
    max_gcd = temp_gcd

print(max_gcd)

### FIXED CODE ###

from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

L = [0]
R = [0]
for i in range(N-1):
  L.append(gcd(L[i],A[i]))
  R.append(gcd(R[i],A[-i-1]))

max_gcd = 0
for i in range(N):
  max_gcd = max(max_gcd, gcd(L[i],R[-i-1]))

print(max_gcd)
### BUGGY CODE ###

def setR(a, b):
  if a in R: R[a].append(b)
  else: R[a] = [b]
                
def set(a, b, d):
  setR(a, b)
  setR(b, a)
  D[a][b] = min(D[a][b], d)
  D[b][a] = min(D[b][a], d)

N = int(input())
xy = [[i] + list(map(int, input().split())) for i in range(N)]
M = 10 ** 20
R = {}
D = [[M] * N for _ in range(N)]
xy.sort(key = lambda x: x[1])
for i in range(1, N):
  a = xy[i]
  b = xy[i - 1]
  d = abs(a[1] - b[1])
  set(a[0], b[0], d)
xy.sort(key = lambda x: x[2])
for i in range(1, N):
  a = xy[i]
  b = xy[i - 1]
  d = abs(a[2] - b[2])
  set(a[0], b[0], d)

import heapq
q = [[0, 0]]
L = [True] * N
pop = heapq.heappop
push = heapq.heappush
ans = 0
for _ in range(N):
  k, t = pop(q)
  while not L[t]:
    k, t = pop(q)
  L[t] = False
  ans += k
  for i in R[t]:
    if L[i]:
      push(q, [D[t][i], i])
print(ans)

### FIXED CODE ###

def set(a, b):
  R[a].append(b)
  R[b].append(a)

N = int(input())
xy = [[i] + list(map(int, input().split())) for i in range(N)]
R = [[] for _ in range(N)]
xy.sort(key = lambda x: x[1])
for i in range(1, N):
  a = xy[i]
  b = xy[i - 1]
  set(a[0], b[0])
xy.sort(key = lambda x: x[2])
for i in range(1, N):
  a = xy[i]
  b = xy[i - 1]
  set(a[0], b[0])

xy.sort()
import heapq
q = [[0, 0]]
L = [True] * N
pop = heapq.heappop
push = heapq.heappush
ans = 0

for _ in range(N):
  k, t = pop(q)
  while not L[t]:
    k, t = pop(q)
  L[t] = False
  ans += k
  for i in R[t]:
    if L[i]:
      x = abs(xy[t][1] - xy[i][1])
      x = min(x, abs(xy[t][2] - xy[i][2]))
      push(q, [x, i])
print(ans)
### BUGGY CODE ###

from itertools import combinations
N, S = int(input()), input()
result = set()
for indexes in combinations(range(N, 0, -1), N - 3):
    tmp = S
    for i in indexes:
        tmp = tmp[:i - 1] + tmp[i:]
    result.add(tmp)
print(len(result))


### FIXED CODE ###

N = input()
S = input()
count = 0
for i in range(1000):
    n = "{:03d}".format(i)
    n1, n2, n3 = n[0], n[1], n[2]
    i1 = S.find(n1)
    if -1 < i1 < len(S) - 2:
        S1 = S[i1 + 1:]
        i2 = S1.find(n2)
        if -1 < i2 < len(S1) - 1:
            S2 = S1[i2 + 1:]
            i3 = S2.find(n3)
            if -1 < i3:
                count += 1
                continue
print(count)
### BUGGY CODE ###

N=input()
A=[int(x)for x in input().split()]
B=[0]
C=[]
for x in A:
  i=B[-1]+x
  B.append(i)
  if i not in C:
    C.append(i)

count=0

for x in C:
  i=B.count(x)
  if i>1:
    count+=(i-1)*i//2
print(count)

### FIXED CODE ###

import collections
N=input()
A=[int(x)for x in input().split()]
B=[0]
count=0
for x in A:
  i=B[-1]+x
  B.append(i)

dic=collections.Counter(B)
for key,c in dic.items():
  count+=c*(c-1)//2
print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
N,Q =  map(int,input().split())
graph = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

val = [0 for i in range(N)]
for i in range(Q):
    a,b = map(int,input().split())
    val[a-1] += b 

def dps(i,parent): 
    for j in graph[i]:
        if j == parent:
            continue
        val[j] += val[i]
        dps(j,i)
                
dps(0,0)
for i in val:
    print(i,end=" ")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
readline = sys.stdin.readline
N,Q =  map(int,input().split())
graph = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,readline().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

val = [0 for i in range(N)]
for i in range(Q):
    a,b = map(int,readline().split())
    val[a-1] += b 

def dps(i,parent): 
    for j in graph[i]:
        if j == parent:
            continue
        val[j] += val[i]
        dps(j,i)
                
dps(0,-1)
print(*val)
### BUGGY CODE ###

n = int(input())
w_l = [input() for _ in range(n)]

d = {}

for w in w_l:
    if d.get(w, 0) == 0:
        d[w] = 1
    else:
        d[w] += 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]

max_k_list.sort()
for k in max_k_list:
    print(k)




### FIXED CODE ###

import collections


n = int(input())
w_l = [input() for _ in range(n)]

counter = collections.Counter(w_l)

c_l = counter.most_common()
max_v = c_l[0][1]
ans_l = []
for i in range(len(c_l)):
    word, num = c_l[i]
    if max_v != num:
        break
    ans_l.append(word)

ans_l.sort()
for ans in ans_l:
    print(ans)
### BUGGY CODE ###

N = int(input())
S = input()
 
ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        if S[i] == S[j]:
            continue
        for k in range(j + 1, N):
            if j - i == k - j:
                continue
            if S[i] != S[k] and S[j] != S[k]:
                ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
all = r * g * b

sub = 0
for i in range(N-1):
    for j in range(i, N):
        k = 2 * j - i
        if k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            sub += 1
print(all - sub)
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(m):
  a.sort()
  a[-1]=a[-1]//2
print(sum(a))

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)
for _ in range(m):
  b=heapq.heappop(a)
  heapq.heappush(a,-(-b//2))
print(-sum(a))
### BUGGY CODE ###

from itertools import permutations as pp
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
fir = []
sec = []
ans = n
ansf = n
for i in range(3):
  if a[i]>b[i]:
    sec.append((a[i],b[i]))
    fir.append((n,n))
  else:
    sec.append((n,n))
    fir.append((b[i],a[i]))
for p in range(n//fir[0][1]+1):
  for q in range((n-p*fir[0][1])//fir[1][1]+1):
    rg = n - p*fir[0][1] - q*fir[1][1]
    if rg < 0:
      continue
    res = rg%fir[2][1]
    r = rg//fir[2][1]
    en = p*fir[0][0] + q*fir[1][0] + r*fir[2][0] + res
    if ansf < en:
      ansf = en
for p in range(ansf//sec[0][1]+1):
  for q in range((ansf-p*sec[0][1])//sec[1][1]+1):
    rg = ansf - p*sec[0][1] - q*sec[1][1]
    if rg < 0:
      continue
    res = rg%sec[2][1]
    r = rg//sec[2][1]
    en = p*sec[0][0] + q*sec[1][0] + r*sec[2][0] + res
    if ans < en:
      ans = en
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0]*(n+1)
fir = []
sec = []
for i in range(3):
  if a[i]>b[i]:
    sec.append((b[i],a[i]))
  else:
    fir.append((a[i],b[i]))
for i in range(1,n+1):
  dp[i] = i
  for x,y in fir:
    if i-x >= 0:
      dp[i] = max(dp[i],dp[i-x]+y)
n = dp[n]
dp = [0]*(n+1)
for i in range(1,n+1):
  dp[i] = i
  for x,y in sec:
    if i-x >= 0:
      dp[i] = max(dp[i],dp[i-x]+y)
print(dp[n])
### BUGGY CODE ###

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

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [[] for _ in range(N)]
for row in sys.stdin.readlines():
    x,y = map(int,row.split())
    graph[x-1].append(y-1)
    graph[y-1].append(x-1)

ldp = [None] * N
rdp = [None] * N

def dfs_1(v=0,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    graph[v] = [w for w in graph[v] if w != parent]
    ldp[v] = [1] * (len(graph[v])+1)
    rdp[v] = [1] * (len(graph[v])+1)
    vals = [dfs_1(w,v)+1 for w in graph[v]]
    for i,x in enumerate(vals,1):
        ldp[v][i] = ldp[v][i-1] * x % MOD
    for i,x in enumerate(vals[::-1],1):
        rdp[v][-i-1] = rdp[v][-i] * x % MOD
    return ldp[v][-1]

dfs_1()

def dfs_2(v=0,x=1):
    # それぞれの子以外の情報をマージして、子に渡さなければいけない
    dp[v] = x * ldp[v][-1] % MOD
    for w,p,q in zip(graph[v],ldp[v][:-1],rdp[v][1:]):
        dfs_2(w,x*p*q%MOD+1)

dp = [None] * N
dfs_2()

print('\n'.join(map(str,dp)))

### FIXED CODE ###

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

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N)]
for row in sys.stdin.readlines():
    x,y = map(int,row.split())
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

ldp = [None] * N
rdp = [None] * N

def dfs_1(v=0,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    graph[v].discard(parent)
    ldp[v] = [1] * (len(graph[v])+1)
    rdp[v] = [1] * (len(graph[v])+1)
    vals = [dfs_1(w,v)+1 for w in graph[v]]
    for i,x in enumerate(vals,1):
        ldp[v][i] = ldp[v][i-1] * x % MOD
    for i,x in enumerate(reversed(vals),1):
        rdp[v][-i-1] = rdp[v][-i] * x % MOD
    return ldp[v][-1]

dfs_1()

dp = [None] * N
q = [(0,1)]
while q:
    v,x = q.pop()
    dp[v] = x*ldp[v][-1]%MOD
    for w,L,R in zip(graph[v],ldp[v][:-1],rdp[v][1:]):
        q.append((w,x*L*R%MOD+1))

print('\n'.join(map(str,dp)))
### BUGGY CODE ###

import heapq
def SME(start,end):
    A = []
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        
        if sum(ANS[a[1]:a[1]+L]) < MAX + len(ANS[a[1]:a[1]+L]) - 1 : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] == MAX:
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] == MAX : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] == MAX : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS

[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
parameter = 0.9995
MAX = 10**9+1
ANS = [MAX]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

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

if N % 2 == 1:
    for i in range(N // 2):
        if A.count(i * 2) != 2 and i != 0:
            print(0)
            exit()
        if i == 0 and A.count(i) != 1:
            print(0)
            exit()

if N % 2 == 0:
    for i in range(N // 2):
        if A.count(i * 2 + 1) != 2:
            print(0)
            exit()

print(2 ** (N // 2))


### FIXED CODE ###

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

check = True
A = sorted(A)
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0 and A[i] != i + 1:
            check = False
        if i % 2 == 1 and A[i] != i:
            check = False

if N % 2 != 0:
    for i in range(N):
        if i % 2 == 0 and A[i] != i:
            check = False
        if i % 2 == 1 and A[i] != i + 1:
            check = False

if check:
    print((2 ** (N // 2)) % (10 ** 9 + 7))
else:
    print(0)
### BUGGY CODE ###

N = int(input())
nu = [int(x) for x in input().split()]
r2 = {}

for i in nu:
  r2[i] = nu.index(i)
#print(r2)

j2 = []
for i in range(len(r2)):
  j2.append(r2[i+1]+1)
#print(j2)

answ = ""
for i in j2:
  #answ = answ + str(i) + " "
  print(i, end=" ")
print(answ)


### FIXED CODE ###

from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    n = int(input())
    students = [int(x) for x in input().split()]
    ret = [0] * n
    for i in range(n):
        ret[students[i] - 1] = i + 1
    print(" ".join([str(x) for x in ret]))
    return


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

S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,len(S)-i+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print(sorted(now_subset)[K-1])
    exit()
    

### FIXED CODE ###

S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,min(K,len(S)-i)+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print(sorted(now_subset)[K-1])
    exit()
### BUGGY CODE ###

H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [None]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i] = dist(a2pos[i+D], a2pos[i])
  

q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  ans = 0
  now = l
  while now != r:
    ans += a2dist[now]
    now += D
  print(ans)


### FIXED CODE ###

H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [0]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i+D] = a2dist[i]+dist(a2pos[i],a2pos[i+D])
  
q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  print(a2dist[r]-a2dist[l])