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

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

mod = 10**9+7

bin_a = []

for i in range(n):
    bin_a.append(format(a[i],'060b'))

ans = 0

for i in range(60):
    one = 0
    zero = 0
    for j in range(n):
        #print(bin_a[j])
        if bin_a[j][i] == '1':
            one += 1
        else:
            zero += 1
    #print(i,zero,one)
    ans += zero * one * (2**(59-i))
    
print(ans%mod)

### FIXED CODE ###

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

mod = 10**9+7

bin_a = []

for i in range(n):
    bin_a.append(format(a[i],'060b'))

ans = 0

for i in range(60):
    one = 0
    zero = 0
    for j in range(n):
        #print(bin_a[j])
        if bin_a[j][i] == '1':
            one += 1
        else:
            zero += 1
    #print(i,zero,one)
    ans += zero * one * (2**(59-i))
    
print(ans%mod)
### BUGGY CODE ###

import numpy as np

hint = list(map(int, input().split()))
a = []
for i in range(hint[0]):
    a.append(int(input()))
b = []
for i in range(hint[1]):
    b.append(int(input()))
c = []
for i in range(hint[2]):
    c.append(int(input()))

a = np.asarray(a)
b = np.asarray(b)
sum = 0
for t in c:
    a_dis = a[np.argmin(np.abs(a-t))]
    b_dis = b[np.argmin(np.abs(b-t))]
    a_d = np.abs(a_dis-t)
    b_d = np.abs(b_dis-t)
    cand1 = b_d + np.min(np.abs(a-b_dis))
    cand2 = a_d + np.min(np.abs(b-a_dis))
    print(np.min([cand1, cand2]))

### FIXED CODE ###

import bisect
import numpy as np
 
hint = list(map(int, input().split()))
s = [int(input()) for i in range(sum(hint))]
# print(s)

def search_min_pos(arr, target):
  index = bisect.bisect_left(arr, target)
  if 0 == index:
    dist = arr[index]
  else:
    dist = arr[index-1:index+1]
  if not isinstance(dist, list):
    dist = [dist]
  return dist

a_arr = s[:hint[0]]
b_arr = s[hint[0]:-hint[2]]
sum = 0
for t in s[-hint[2]:]:
  a_pos = search_min_pos(a_arr, t)
  b_pos = search_min_pos(b_arr, t)
  #print(t, a_pos, b_pos)
  min_dist = 10 ** 11
  for a in a_pos:
    b_against_a = search_min_pos(b_arr, a)
    for ba in b_against_a:
      min_dist = min([min_dist, abs(t-a)+abs(ba-a)])
  for b in b_pos:
    a_against_b = search_min_pos(a_arr, b)
    for ab in a_against_b:
      min_dist = min([min_dist, abs(t-b)+abs(ab-b)])
  print(min_dist)
### BUGGY CODE ###

H,W= list(map(int,input().split()))
l=[list(input()) for i in range(H)]
inf=10**9
visited=[[inf]*W for i in range(H)]
from collections import deque
def ans():
   que=deque([])
   for i in range(H):
      for j in range(W):
         if l[i][j]=="#":
            que.append((i,j))
            visited[i][j]=0
   while que:
      y,x=que.popleft()
      node=visited[y][x]+1
      if y>0:
         if l[y-1][x]=="." and visited[y-1][x]==inf:
            visited[y-1][x]=min(visited[y-1][x],node)
            que.append((y-1,x))
      if x>0:
         if l[y][x-1]=="." and visited[y][x-1]==inf:
            visited[y][x-1]=min(visited[y][x-1],node)
            que.append((y,x-1))
      if H-1>y:
         if l[y+1][x]=="." and visited[y+1][x]==inf:
            visited[y+1][x]=min(visited[y+1][x],node)
            que.append((y+1,x))
      if W-1>x:
         if l[y][x+1]=="." and visited[y][x+1]==inf:
            visited[y][x+1]=min(visited[y][x+1],node)
            que.append((y,x+1))
ans()
visited=sum(visited,[])
print(max(visited))

### FIXED CODE ###

H,W=list(map(int,input().split()))
inf=float("inf")
import numpy as np
mem=np.full((H,W),inf)
l=[list(input()) for i in range(H)]
for i in range(H):
   for j in range(W):
      if l[i][j]=="#":
         mem[i,j]=0
for i in range(W-1):
   mem[:,i+1]=np.minimum(mem[:,i]+1,mem[:,i+1])
for i in reversed(range(1,W)):
   mem[:,i-1]=np.minimum(mem[:,i-1],mem[:,i]+1)
for i in range(H-1):
   mem[i+1,:]=np.minimum(mem[i+1,:],mem[i,:]+1)
for i in reversed(range(1,H)):
   mem[i-1,:]=np.minimum(mem[i-1,:],mem[i,:]+1)
print(int(np.max(mem)))
### BUGGY CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
S = set(A)
cnt = 0

for i in S:
    m = A.count(i)
    if m % 2 == 1:
        cnt += 1

print(cnt)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
S = sorted(A)
cnt = 0

for i in range(N):
    if i == 0:
        tmpnum = S[i]
        tmpcnt = 1
    else:
        if S[i] == tmpnum:
            tmpcnt += 1
        else:
            if tmpcnt % 2 != 0:
                cnt += 1
            tmpnum = S[i]
            tmpcnt = 1

if tmpcnt % 2 != 0:
    cnt += 1
            
print(cnt)
### BUGGY CODE ###

n,k=map(int,input().split())
*p,=map(int,input().split())
px=[]
for i in p:
	s=(i*(i+1))/2
	s1=s/i
	px.append(s1)
ans=[]
for i in range(n-k+1):
	x=sum(px[i:i+k])
	ans.append(x)
print(max(ans))
	
	

### FIXED CODE ###

n,k=map(int,input().split())
*p,=map(int,input().split())
px=[(i+1)/2 for i in p]
px_sum=[0]
for j in range(len(px)):
	px_sum.append(px_sum[j]+px[j])
ans=0
for i in range(n-k+1):
	a=px_sum[i+k]-px_sum[i]
	ans=max(a,ans)
print(ans)
### BUGGY CODE ###

import fractions

K = int(input())
g = 0
for i in range(1, K+1):
    for j in range(1, i+1):
        for k in range(1, j+1):
            a = fractions.gcd(i, j)
            b = fractions.gcd(a, k)
            if i != j != k:
                g += b*6
            elif i == j == k:
                g += b
            else:
                g += b*3


print(g)


### FIXED CODE ###

import math

K = int(input())
g = 0
for i in range(1, K+1):
    for j in range(1, i+1):
        for k in range(1, j+1):
            a = math.gcd(i, j)
            b = math.gcd(a, k)
            if i != j != k:
                g += b*6
            elif i == j == k:
                g += b
            else:
                g += b*3

print(g)
### BUGGY CODE ###

S = input()
count = 0
S1 = S
S2 = ''
while S1 != S2:
    S2 = S1
    S1 = S1.replace('01','',-1).replace('10','',-1)
print(len(S)-len(S2))

### FIXED CODE ###

S = input()
a = S.count('0')
b = S.count('1')
print(min(a,b)*2)
### BUGGY CODE ###

k, s = map(int, input().split())

idx = 0
for x in range(k+1):
    for y in range(k+1):
        if x+y > s:
            continue
        for z in range(k+1):
            if s == x+y+z:
                idx += 1


print(idx)


### FIXED CODE ###

k, s = map(int, input().split())

idx = 0


for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            idx += 1

print(idx)
### BUGGY CODE ###

N=int(input())
li=list(map(int,input().split()))
ans=[]
for n in range(N):
    a=str(li[n])
    ans.append(a)
    ans.reverse()
print(' '.join(ans))


### FIXED CODE ###

N=int(input())
li=list(map(int,input().split()))
ans_odd=[]
ans_even=[]
if N%2==0:
    ans_normal=li[::2]
    ans_rev=li[1::2]
else:
    ans_rev=li[::2]
    ans_normal=li[1::2]  
ans_rev.reverse()
ans=ans_rev+ans_normal
for n in range(N):
    ans[n]=str(ans[n])
print(' '.join(ans))
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
s = s[::-1]
dp = [[0]*13 for _ in range(n)]
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for i in range(1,n):
    x = (10**i) % 13
    if s[i] != '?':
        y = int(s[i])
        for j in range(13):
            dp[i][(j+(y*x) % 13) % 13] += dp[i-1][j]
            dp[i][(j+(y*x) % 13) % 13] %= mod
    else:
        for j in range(10):
            for k in range(13):
                dp[i][(k+(j*x) % 13) % 13] += dp[i-1][k]
                dp[i][(k+(j*x) % 13) % 13] %= mod
print(dp[n-1][5])


### FIXED CODE ###

#!/usr/bin/env python3
#ABC135 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

s = list(input())
s = s[::-1]
l = len(s)
#dp[i][j] := 先頭i文字として考えられるもののうち、13で割ったあまりがjであるもの
dp = [[0]*13 for _ in range(l)]
remain = 1
if s[0] == '?':
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1

for i in range(1,l):
    remain = (remain * 10) % 13
    if s[i] == '?':
        for k in range(10):
            for j in range(13):
                dp[i][(j + remain * k) % 13] += dp[i-1][j]
                dp[i][(j + remain * k) % 13] %= mod
    else:
        for j in range(13):
            dp[i][(j + remain * int(s[i])) % 13] += dp[i-1][j]
print(dp[-1][5])
### BUGGY CODE ###

def comb(a, b, mod):
    t = 1
    for i in range(b):
        t *= (a - i) % mod
    s = 1
    for i in range(1, b + 1):
        s *= i % mod
    return (t // s) % mod



N, K = map(int, input().split())
r = N - K
mod = 1000000007
for i in range(1, K + 1):
    print(comb(r + 1, i, mod) * comb(K - 1, i - 1, mod) % mod)




### FIXED CODE ###

def comb(a, b, mod):
    if a < b :
        return 0
    if (a // 2) < b:
        x = a - b
        # print(f'{b}　→ {x}')
        b = x
    t = 1
    for i in range(b):
        t *= (a - i) % mod
    s = 1
    for i in range(1, b + 1):
        s *= i % mod
    return (t // s) % mod

N, K = map(int, input().split())
r = N - K
mod = 1000000007

for i in range(1, K + 1):
        first = comb(r + 1, i, mod)
        if first == 0:
            second = 0
        else:
            second = comb(K - 1, i - 1, mod)
        print(first * second % mod)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    sin = input()
    sin = list(sin)
    sin.sort()
    sin = ''.join(sin)
    s.append(sin)

c = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            c += 1
print(c)


### FIXED CODE ###

import itertools

def comb(n, r):
    return len(list(itertools.combinations(range(n), r)))

def get_runlength(s): # ex) s = 'RRLLLLRLRLRLRR'
    ret = []
    count = 1
    for i in range(len(s)):
        if i == len(s) - 1:
            ret.append((s[i], count))
            continue
        if s[i] == s[i + 1]:
            count += 1
        else:
            ret.append((s[i], count))
            count = 1
    return ret

n = int(input())
dic = {}
for i in range(n):
    sin = input()
    sin = list(sin)
    sin.sort()
    sin = ''.join(sin)
    try:
        dic[sin] += 1
    except:
        dic[sin] = 1

count = 0
for v in dic.values():
    count += v * (v - 1) / 2
count = int(count)
print(count)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = str(input())
 
ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]

for _ in range(Q):
  l, r = map(int, input().split())
  print(sum(ac[l-1:r-1]))

### FIXED CODE ###

N, Q = map(int, input().split())
S = str(input())
 
#ac = [1 if S[i] == 'A' and S[i+1] == 'C' else 0 for i in range(N-1) ]
a = 0
lst = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    a += 1
  lst.append(a)
for _ in range(Q):
  l, r = map(int, input().split())
  print(lst[r-1] - lst[l-1])
### BUGGY CODE ###

def main():    
    from collections import deque
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    e = [[] for i in range(n)]

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


    dis = [False]*n

    def search(x):

        q = deque([])
        dis[x] = 0
        q.append((x,0))
        while q:
            now,cnt = q.popleft()
            for nex,d in e[now]:
                if dis[nex] == False:
                    dis[nex] = cnt+d
                    q.append((nex,cnt+d))
                else:
                    if dis[nex] != cnt+d:
                        print("No")
                        exit()
            
    for i in range(n):
        if e[i] and dis[i] == False:
            search(i)
    print("Yes")

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():    
    from collections import deque
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    e = [[] for i in range(n)]

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


    dis = [float("INF")]*n

    def search(x):

        q = deque([])
        dis[x] = 0
        q.append((x,0))
        while q:
            now,cnt = q.popleft()
            for nex,d in e[now]:
                if dis[nex] == float("INF"):
                    dis[nex] = cnt+d
                    q.append((nex,cnt+d))
                else:
                    if dis[nex] != cnt+d:
                        print("No")
                        exit()
            
    for i in range(n):
        if e[i] and dis[i] == float("INF"):
            search(i)
    print("Yes")

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

H, W = map(int,input().split())
G = [input() for k in range(H)]

def keisan(h,w):
    k = 0
    while h-k>=0:
        if G[h-k][w] == ".":
            k += 1
        else:
            break
    l = 0
    while h+l<H:
        if G[h+l][w] == ".":
            l += 1
        else:
            break
    m = 0
    while w-m>=0:
        if G[h][w-m] == ".":
            m += 1
        else:
            break
    n = 0
    while w+n < W:
        if G[h][w+n] == ".":
            n += 1
        else:
            break
    return k+l+m+n-3

ans = 0
for h in range(H):
    for w in range(W):
        if G[h][w] == ".":
                ans = max(ans,keisan(h,w))
print(ans)


### FIXED CODE ###

H, W = map(int,input().split())
G = [input() for k in range(H)]
yoko = [[0 for k in range(W)] for k in range(H)]
tate = [[0 for k in range(W)] for k in range(H)]


for h in range(H):
    t = 0
    s = 0
    for w in range(W):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,w):
                    yoko[h][k] = t
            s = w+1
            t = 0
    if t > 0:
        for k in range(s,W):
            yoko[h][k] = t


for w in range(W):
    t = 0
    s = 0
    for h in range(H):
        if G[h][w] == ".":
            t += 1
        else:
            if t > 0:
                for k in range(s,h):
                    tate[k][w] = t
            s = h+1
            t = 0
    if t > 0:
        for k in range(s,H):
            tate[k][w] = t

ans = 0
for w in range(W):
    for h in range(H):
        ans = max(ans,tate[h][w]+yoko[h][w]-1)
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
f = [False]*N
f2 = [False]*N
l = 0
r = 1
for i in range(M):
    flag = True
    while flag:
        if f[l] or f[r]:
            l += 1
            r += 1
            l %= N
            r %= N
            continue
        if f2[min(abs(r-l), N-abs(r-l))]:
            r += 1
            r %= N
            continue
        if N%2 == 0:
            if abs(r-l) == N//2:
                r += 1
                r %= N
        flag = False
    f[l] = True
    f[r] = True
    f2[min(abs(r-l), N-abs(r-l))] = True
    print(l+1, r+1)

### FIXED CODE ###

N, M = map(int, input().split())
f = [False]*N
l = 0
r = N+1
for i in range(M):
    l += 1
    r -= 1
    while True:
        if N % 2 == 0:
            if r-l == N//2:
                r -= 1
                continue
        if f[min(r-l, N-(r-l))]:
            r -= 1
            continue
        break
            
    f[min(r-l, N-(r-l))] = True
    print(l, r)
### BUGGY CODE ###

import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
count = 0
for i in range(n):
  for s in range(bisect.bisect_right(b, a[i]),n):
    count += n-bisect.bisect_right(c, b[s])
print(count)

### FIXED CODE ###

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

import bisect
ans=0
for i in b:
    q=bisect.bisect_left(a,i)
    s=bisect.bisect_right(c,i)
    ans=ans+q*(n-s)
print(ans)
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input())

tmp = s[:]
tmp = list(set(tmp))
cnt = []
# for i in tmp:
#     cnt.append([i, s.count(i)])
for i in tmp:
    cnt.append(s.count(i))

maxIndex = [i for i,v in enumerate(cnt) if v == max(cnt)]

ans = []
for i in maxIndex:
    ans.append(tmp[i])
# m = 0
# for i in cnt:
#     if m == i[1]:
#         ans.append(i[0])
#     elif m < i[1]:
#         ans.clear()
#         ans.append(i[0])
#         m = i[1]

ans.sort()
for i in ans:
    print(i)

### FIXED CODE ###

from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = 0
for v in c.values():
	m = max(m, v)
ans = []
for k, v in c.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")
### BUGGY CODE ###

import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 6)


R, C, K = [int(x) for x in input().split()]
grid = [[0 for c in range(C)] for r in range(R)]
for r, c, v in [[int(x) for x in input().split()] for i in range(K)]:
    grid[r - 1][c - 1] = v


'''
    def best3(r, c1, c2):  # c1 inclusive, c2 exclusive
        return sum(sorted(grid[r][c1:c2], reverse=True)[:3])

    @lru_cache(maxsize=None)
    def dp(r, c):  # inclusive
        if r < 0 or c < 0:
            return 0
        best = 0
        for c1 in range(c + 1):
            best = max(best, dp(r - 1, c1) + best3(r, c1, c + 1))
        return best

    print(dp(R - 1, C - 1))

'''
inf = float("inf")

@lru_cache(maxsize=None)
def dp(r, c, numTakenThisRow):
    if numTakenThisRow < 0:
        return -inf
    if r < 0 or c < 0:
        return 0

    best = max(
        dp(r, c - 1, numTakenThisRow),
        dp(r, c - 1, numTakenThisRow - 1) + grid[r][c],
    )
    if numTakenThisRow == 0:
        best = max(best, max(dp(r - 1, c, i) for i in range(3 + 1)),)
    if numTakenThisRow == 1:
        best = max(best, max(dp(r - 1, c, i) + grid[r][c] for i in range(3 + 1)),)

    return best

print(max(dp(R - 1, C - 1, i) for i in range(3 + 1)))


### FIXED CODE ###

import io
import os
from collections import defaultdict

DEBUG = False
if not DEBUG:

    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    R, C, K = [int(x) for x in input().split()]
    grid = [[0 for c in range(C)] for r in range(R)]
    for r, c, v in ((int(x) for x in input().split()) for i in range(K)):
        grid[r - 1][c - 1] = v
else:
    import random

    random.seed(0)
    R, C = 3000, 3000
    # 2 * 10**5 / 90 * 10**5 full
    grid = [
        [int(random.randint(1, 90) <= 2) * random.randint(0, 10 ** 9) for c in range(C)]
        for r in range(R)
    ]
    print(sum(bool(grid[r][c]) for r in range(R) for c in range(C)))
    print("done gen")

    from timeit import default_timer as timer

    startTime = timer()


currRow = [[0 for i in range(3 + 1)] for c in range(C + 1)]
prevRow = [0 for c in range(C + 1)]
nextPrevRow = [0 for c in range(C + 1)]

inf = float("inf")
for r in range(R):
    for c in range(C):
        for numTakenThisRow in range(3 + 1):
            best = max(
                currRow[c - 1][numTakenThisRow],  # came from left
                prevRow[c],  # came from top, didn't take curr
                currRow[c - 1][numTakenThisRow - 1] + grid[r][c]
                if numTakenThisRow
                else 0,  # came from left, took curr
                prevRow[c] + grid[r][c]
                if numTakenThisRow == 1
                else 0,  # came from top, took curr
            )
            currRow[c][numTakenThisRow] = best
        nextPrevRow[c] = max(currRow[c][i] for i in range(3 + 1))
    prevRow, nextPrevRow = nextPrevRow, prevRow
print(prevRow[C - 1])

if DEBUG:
    print(timer() - startTime)
### BUGGY CODE ###

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


def mostProperComb(childs, x):
    if sum([c[1] for c in childs]) > x:
        print("IMPOSSIBLE")
        exit()
    loop = 2**len(childs)
    max_a, min_b = 0, 0
    for i in range(loop):
        a, b = 0, 0
        code = bin(loop-i-1)[2:].zfill(len(childs))
        for j, color in enumerate(code):
            if color == '1':
                a += childs[j][1]
                b += childs[j][0]
            elif color == '0':
                a += childs[j][0]
                b += childs[j][1]
        if a >= max_a and x >= a:
            max_a, min_b = a, b
            if max_a == x:
                break

    return (max([x, min_b]), min([x, min_b]))


n = int(input())

p_list = [0] + list(map(int, input().split()))
x_list = list(map(int, input().split()))
c_list = [[] for i in range(n)]

if n == 1:
  print("POSSIBLE")
  exit()

for i in range(n):
    index = n-1-i

    if len(c_list[index]) == 0:
        c_list[index] = (x_list[index], 0)
        c_list[p_list[index]-1].append(index)
    else:
        childs = [c_list[child_index] for child_index in c_list[index]]
        c_list[index] = mostProperComb(childs, x_list[index])
        if not p_list[index] == 0:
            c_list[p_list[index]-1].append(index)

print("POSSIBLE")


### FIXED CODE ###

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

import itertools


def mostProperComb(childs, x):
    tmp_sum = sum([c[1] for c in childs])
    if tmp_sum > x:
        print("IMPOSSIBLE")
        exit()

    total = tmp_sum + sum([c[0] for c in childs])

    sset = set([tmp_sum])
    for child in childs:
        rest = child[0] - child[1]
        tmp_set = set(sset)
        for s in sset:
            if s + rest <= x:
                tmp_set.add(s+rest)
        sset = tmp_set

    return (tuple(sorted([x, total-max(sset)], reverse=True)))


n = int(input())

p_list = [0] + list(map(int, input().split()))
x_list = list(map(int, input().split()))
c_list = [[] for i in range(n)]

if n == 1:
    print("POSSIBLE")
    exit()

for i in range(n):
    index = n-1-i

    if len(c_list[index]) == 0:
        c_list[index] = (x_list[index], 0)
        c_list[p_list[index]-1].append(index)
    else:
        childs = [c_list[child_index] for child_index in c_list[index]]
        c_list[index] = mostProperComb(childs, x_list[index])
        if not p_list[index] == 0:
            c_list[p_list[index]-1].append(index)

print("POSSIBLE")
### BUGGY CODE ###

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

S = [0] * (H*W)
for i in reversed(range(H*W-D)):
    tmp1 = (0, 0)
    tmp2 = (0, 0)
    for j, Ai in enumerate(A):
        if i+1 in Ai:
            tmp1 = (Ai.index(i+1), j)
        if i+D+1 in Ai:
            tmp2 = (Ai.index(i+D+1), j)
    S[i] = abs(tmp1[0] - tmp2[0]) + abs(tmp1[1] - tmp2[1]) + S[i + D]

for L, R in exam:
    print(S[L-1] - S[R-1])



### FIXED CODE ###

from itertools import chain

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

x_a = [0] * (H*W)
y_a = [0] * (H*W)

for i, ax in enumerate(A):
    for j, ay in enumerate(ax):
        x_a[ay-1] = i
        y_a[ay-1] = j

S = [0] * (H*W)
for i in reversed(range(H*W-D)):
    S[i] = abs(x_a[i] - x_a[i+D]) + abs(y_a[i] - y_a[i+D]) + S[i + D]

for L, R in exam:
    print(S[L-1] - S[R-1])
### BUGGY CODE ###

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

for i in a:
    b.append(i)
    b=b[::-1]
print(*b)


### FIXED CODE ###

n=int(input())
a= list(map(int,input().split()))
if n%2 ==1:
    ans = a[::-2]+a[1::2]
else:
    ans = a[::-2]+a[0::2]
print(*ans)