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

import math

H,W,A,B = map(int,input().split())

res1 = math.factorial(H+W-2)//(math.factorial(H-1)*math.factorial(W-1))
res1 = res1 % (10**9 + 7)

res2 = 0

for i in range(B):
    temp1 = math.factorial(H-A-1+i)//(math.factorial(H-A-1)*math.factorial(i))
    temp1 = temp1 % (10**9 + 7)
    if A == 1:
        temp2 = 1
    else:
        temp2 = math.factorial(W+A-i-2)//(math.factorial(A-1)*math.factorial(W-i-1))
        temp2 = temp2 % (10**9 + 7)
    res2 += temp1 * temp2
    res2 = res2 % (10**9 + 7)

res = res1 - res2
res = res % (10**9 + 7)

print(res)


### FIXED CODE ###

H,W,A,B = map(int,input().split())

mod = 10**9 + 7

f = [1]
for i in range(H+W):
    f.append(f[i]*(i+1)%mod)

def comb(A,B,mod):
    return f[A] * pow(f[B],mod-2,mod) * pow(f[A-B],mod-2,mod) % mod

res = 0

for i in range(B,W):
    res += comb(H-A+i-1,i,mod) * comb(A+W-i-2,A-1,mod) % mod

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

import sys
from heapq import heappush, heappop

input = sys.stdin.readline
n, m = map(int, input().split())
heap = []

for i in map(int, input().split()):
  heappush(heap, i)

bc = [list(map(int, input().split())) for _ in range(m)]

for b, c in bc:
  for j in range(b):
    a = heappop(heap)
    if a < c:
      heappush(heap, c)
    else:
      heappush(heap, a)
print(sum(heap))

### FIXED CODE ###

import sys
from heapq import heappush, heappop

input = sys.stdin.readline
n, m = map(int, input().split())
heap = []

for i in map(int, input().split()):
  heappush(heap, i)

bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key = lambda x: -x[1])#cが大きいものから順に操作を加える

for b,c in bc:
  for j in range(b):
    a = heappop(heap)
    if a < c:
      heappush(heap, c)
    else:
      heappush(heap, a)
      break
print(sum(heap))
### BUGGY CODE ###

import numpy as np;




if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    for a in A:
        ans *= a
    
    if ans > 10 ** 18:
        print(-1)
        quit()
    print(ans)



### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = 1
for a in A:
    ans *= a
    if ans > 1000000000000000000:
            print(-1)
            quit()
print(ans)
### BUGGY CODE ###

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

R, C, k = (int(x) for x in input().split())
V = [[0] * (C + 5) for _ in range(R + 5)]
for _ in range(k):
    r, c, v = (int(x) for x in input().split())
    V[r][c] = v

# dp[i][j][3]
dp = [[[0] * 4 for _ in range(C + 5)] for _ in range(R + 5)]
for i in range(1, R + 3):
    for j in range(1, C + 3):
        for k in range(4):
            # 行移動
            dp[i][j][0] = max(dp[i][j][0], max(dp[i-1][j]))
            dp[i][j][1] = max(dp[i][j][1], max(dp[i-1][j])+V[i][j])
            # 列移動
            if k > 0:
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k - 1] + V[i][j])
            dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k])
print(max(dp[R][C]))

### FIXED CODE ###

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

R, C, k = (int(x) for x in input().split())
V = [[0] * (C + 5) for _ in range(R + 5)]
for _ in range(k):
    r, c, v = (int(x) for x in input().split())
    V[r][c] = v

# dp[3][i][j]
dp = [[[0] * (C + 5) for _ in range(R + 5)] for _ in range(4)]
for i in range(R + 3):
    for j in range(C + 3):
        for k in range(4):
            # 行移動
            dp[0][i + 1][j] = max(dp[0][i + 1][j], dp[k][i][j])
            dp[1][i + 1][j] = max(dp[1][i + 1][j], dp[k][i][j] + V[i + 1][j])
            # 列移動
            dp[k][i][j + 1] = max(dp[k][i][j + 1], dp[k][i][j])
            if k < 3:
                dp[k + 1][i][j + 1] = max(dp[k + 1][i][j + 1], dp[k][i][j] + V[i][j + 1])
print(max(dp[k][R][C] for k in range(4)))
### BUGGY CODE ###

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += (lcm_ // A[i]) % mod

print(ans % mod)


### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

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

import math
H, W, A, B = map(int, input().split())

MOD = 10 ** 9 + 7
first = []
for i in range(0, H - A):
    if i == 0:
        tmp = 1
        first.append(tmp)
        continue
    tmp = (tmp * (B + i - 1) // i)
    first.append(tmp)

# print (first)

second = []
for i in range(H - A):
    if i == 0:
        tmp = (math.factorial(A + (W - B - 1)) // (math.factorial(A) * math.factorial(W - B - 1)))
        second.append(tmp)
        continue
    tmp = ((tmp * (A + (W - B - 1) + i)) // (A + i))
    second.append(tmp)

# print (second)

ans = 0
for i in range(H - A):
    ans = (ans + first[i] * second[H - A - 1 -i]) % MOD

print (ans)


### FIXED CODE ###


def modinv(a, m): #mod. m でのaの逆元 a^{-1}を計算する
    b = m
    u = 1
    v = 0
    while b:
        t = a//b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    
    u %= m
    if u < 0:
        u += m
    return u

H, W, A, B = map(int, input().split())

MOD = 10 ** 9 + 7

#O(N)
first = []
for i in range(0, H - A):
    if i == 0:
        tmp = 1
        first.append(tmp)
        continue
    tmp = (tmp * (B + i - 1) * modinv(i, MOD)) % MOD
    first.append(tmp)

# print (first)

#O(N)
second = []
for i in range(0, H):
    if i == 0:
        tmp = 1
        second.append(tmp)
        continue
    tmp = (tmp * ((W - B) + i - 1) * modinv(i, MOD)) % MOD
    second.append(tmp)

# print (second)

#O(N)
ans = 0
for i in range(H - A):
    ans = (ans + first[i] * second[H - 1 -i]) % MOD

print (ans)
#total O(3 * N) --> O(N)
### BUGGY CODE ###

print(sum(range(int(input()))))

### FIXED CODE ###

n = int(input())
print(n * (n - 1) // 2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

INF = 10**9 + 7

res = 0

for i in range(N-1):
    for j in range(i+1,N):
        res += A[i] ^ A[j]
        res %= INF

print(res)

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.readline

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

A = np.array(A,np.int64)

mod = 10**9 + 7

res = 0

for i in range(60):
    count = np.count_nonzero(A & 1)
    res += (N - count) * count * 2 ** i
    res %= mod
    A >>= 1

print(res)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
a, b = [0], [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

for i in range(n+1):
    j = m
    if a[i] > k:
        break
    while True:
        if a[i] + b[j] <= k:
            break
        j -= 1
    res = max(res, i+j)

print(res)


### FIXED CODE ###

import sys
input = sys.stdin.readline

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
a, b = [0], [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

j = m

for i in range(n+1):
    if a[i] > k:
        break
    while True:
        if a[i] + b[j] <= k:
            break
        j -= 1
    res = max(res, i+j)

print(res)
### BUGGY CODE ###

n = int(input())

for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-n*i-n*j) != 0:
            w = i*j*n/(4*i*j-n*i-n*j)
            if w%1 == 0 and w > 0:
                print(i,j,int(w))
                exit()

### FIXED CODE ###

n = int(input())

for i in range(1,3501):
    for j in range(1,3501):
        if (4*i*j-n*i-n*j) != 0:
            w = i*j*n/(4*i*j-n*i-n*j)
            if w%1 == 0 and w > 0:
                print(i,j,int(w))
                exit()
### BUGGY CODE ###

# coding:utf-8
import math

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

for x in range(1, n + 1):
    tmp = math.floor((a * x) / b) - a * (math.floor(x / b))
    ans = max(tmp, ans)

print(ans)


### FIXED CODE ###

# coding:utf-8

import math

a, b, n = map(int, input().split())
x = min(b - 1, n)

ans = math.floor((a * x) / b) - a * (math.floor(x / b))

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

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

sorted_s = ["".join(sorted(x)) for x in s]

cnt = 0
for i in range(n):
    cnt += sorted_s[i+1:].count(sorted_s[i])

print(cnt)

### FIXED CODE ###

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


cnt = 0
tmpdic = {}
for i in s:
    tmp = "".join(sorted(i))
    if tmp in tmpdic.keys():
        cnt += tmpdic[tmp]
        tmpdic[tmp] += 1
    else:
        tmpdic[tmp] = 1


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

n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.index(i)+1,end=" ")

### FIXED CODE ###

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

dict={}
dict2={}
n,m=map(int,input().split())
for i in range(m):
	p,m=map(int,input().split())
	dict[i]=[p,m]
	if p not in dict2:
		dict2[p]=[m]
	else:
		dict2[p].append(m)
		dict2[p].sort()
for d in dict:
	a='{:0=6}'.format(dict[d][0])
	c=dict2[dict[d][0]].index(dict[d][1])+1
	c='{:0=6}'.format(c)
	print(a+c)

### FIXED CODE ###

n,m=map(int,input().split())
pys=[0]*m
for i in range(m):
	p,y=map(int,input().split())
	pys[i]=(p,y,i)
pys.sort(key=lambda x:x[1])

num=[0]*n
ans=[0]*m
for p,y,i in pys:
	num[p-1]+=1
	ans[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for a in ans:
	print(a)
### BUGGY CODE ###


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10**18
    _sum = 1
    for a in A:
        _sum *= a
    if _sum <= limit:
        print(_sum)
    else:
        print(-1)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    limit = 10**18

    if 0 in A:
        print(0)
        return

    _mul = 1
    for a in A:
        _mul *= a
        if _mul > limit:
            print(-1)
            return

    print(_mul)

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

import sys
import itertools
sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
v = []
for i in range(n):
    v.append((a[i], i+1))
ans = 0
for a, b in itertools.permutations(v, 2):
    if abs(a[1] - b[1]) == a[0] + b[0]:
        ans += 1
print(ans//2)

### FIXED CODE ###

import sys
import bisect
import itertools
sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
b = a.copy()
for i in range(n):
    a[i] += i+1
    b[i] -= i+1
ans = 0
b.sort()
for i in range(n):
    ans += bisect.bisect_right(b, -a[i]) - bisect.bisect_left(b, -a[i])
print(ans)
### BUGGY CODE ###

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

for i in range(m // n + 1)[::-1]:
    if m % i == 0:
        print(i)
        break


### FIXED CODE ###

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

ans = 0
for i in range(1, int(m ** 0.5) + 1)[::-1]:
    if (m % i == 0):
        if m / i >= n:
            ans = max(ans, i)
        if i >= n:
            ans = max(ans, m // i)
print(ans)
### BUGGY CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

import math

# 組み合わせ
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

A.sort(reverse=True)

max_v = 0
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        x = combinations_count(A[i], A[j])
#        print(x, A[i], A[j])
        if x > max_v:
            max_v = x
            ans = (A[i], A[j])

print(*ans)

### FIXED CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

left = max(A)
center = left // 2

right = 0
diff = INF
for i in range(N):
    if A[i] == left:
        continue

    x = abs(center-A[i])
    if diff > x:
        diff = x
        right = A[i]

print(left, right)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in range(1, n + 1):
    ind = a.count(i)
    print(ind)

### FIXED CODE ###

import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
d = {0: 0}
for i in range(1, n + 1):
    d[i] = bisect.bisect_right(a, i)
    print(d[i] - d[i - 1])
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
    b=a.pop(i)
    print(max(a))
    a.insert(i,b)

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
maxa=max(a)
if a.count(maxa)>=2:
    for i in range(n):
        print(maxa)
else:
    maxi=a.index(maxa)
    a.remove(maxa)
    maxa2=max(a)
    for i in range(n):
        if i==maxi:
            print(maxa2)
        else:
            print(maxa)
### BUGGY CODE ###

#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
import collections

N=int(input())
#N,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
A = list(map(int,input().split()))
#S=str(input())
#A=[p for p in range(2*10**5)]
Q=int(input())
l=[]
for i in range(Q):
    #print(A)
    B,C = map(int,input().split())

    A=[C if x==B else x for x in A]
    
    print(sum(A))


### FIXED CODE ###

#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
import collections

N=int(input())
#N,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
A = list(map(int,input().split()))
#S=str(input())
#A=[p for p in range(2*10**5)]
Q=int(input())
c=collections.Counter(A)
s=sum(A)
for i in range(Q):
    #print(A)
    B,C = map(int,input().split())
    if c[B]:
        s += (C-B)*c[B]
        c[C] += c[B]
        c[B] = 0

    print(s)
### BUGGY CODE ###

import math as mt

MAXN = 1000001

spf = [0 for i in range(MAXN)]



def sieve():
    spf[1] = 1
    for i in range(2, MAXN):

        
        spf[i] = i

    for i in range(4, MAXN, 2):
        spf[i] = 2

    for i in range(3, mt.ceil(mt.sqrt(MAXN))):

        if (spf[i] == i):

            for j in range(i * i, MAXN, i):

                if (spf[j] == j):
                    spf[j] = i



def getFactorization(x):
    ret = [0]*(x+1)
    while (x != 1):
        ret[spf[x]]+=1
        x = x // spf[x]

    return ret

sieve()
x = int(input())
ans = 0
for i in range(1,x):
    p = getFactorization(x-i)
    sumi=1
    for i in range(len(p)):
        sumi*=(1+p[i])
    ans+=sumi
print(ans)


### FIXED CODE ###

ans=0
n=int(input())
for i in range(1,n):
  ans+=(n-1)//i
print(ans)
### BUGGY CODE ###

from bisect import bisect_left

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

if X*Y*Z <= 10**5:
  D = sorted([A[i]+B[j]+C[k] for i in range(X) for j in range(Y) for k in range(Z)],reverse=True)
  for i in range(K):
    print(D[i])
  
else:
  A = sorted(A)
  D = sorted([B[i]+C[j] for i in range(Y) for j in range(Z)])

  thr = K
  s = A[-1]+D[0]
  prev_idx=0
  selected = [A[-1] + D[i] for i in range(len(D))]
  for i in range(1,X):
    r = s - A[-1-i]
    if r<=0:break
    idx = bisect_left(D,r,prev_idx,len(D)-1)
    if idx == len(D):break
    selected.extend([A[-1-i] + D[j] for j in range(idx,len(D))])
    prec_idx = idx

  selected = sorted(selected,reverse=True)
  print(len(selected))

  for i in range(K):
    print(selected[i])

### FIXED CODE ###

from bisect import bisect_left

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

if X*Y*Z <= 50000:
  D = sorted([A[i]+B[j]+C[k] for i in range(X) for j in range(Y) for k in range(Z)],reverse=True)
  for i in range(K):
    print(D[i])
  
else:
  A = sorted(A)
  D = sorted([B[i]+C[j] for i in range(Y) for j in range(Z)])

  thr = K
  s = A[-1]+D[max(0,len(D)-thr)]
  prev_idx=0
  selected = [A[-1] + D[i] for i in range(max(0,len(D)-thr),len(D))]
  
  for i in range(1,X):
    r = s - A[-1-i]
    if r<=0:break
    idx = bisect_left(D,r,prev_idx,len(D)-1)
    if idx == len(D):break
    selected.extend([A[-1-i] + D[j] for j in range(idx,len(D))])
    prec_idx = idx

  selected = sorted(selected,reverse=True)

  for i in range(K):
    print(selected[i])
### BUGGY CODE ###

from numba import njit, i8
n, k, *a = map(int, open(0).read().split())

@njit(cache=True)
def c(x, a):
    res = 0
    for b in a:
        res += 0 - - b // x - 1
    return res <= k

ng = 0
ok = 10 ** 9 + 1
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if c(mid, a):
        ok = mid
    else:
        ng = mid
print(ok)


### FIXED CODE ###

n, k, *a = map(int, open(0).read().split())


def c(x):
    res = 0
    for b in a:
        # bを最大がxになるように、できるだけ少ない回数で
        # だいたいb/x等分？
        res += 0 - - b // x - 1
    return res <= k


ng = 0
ok = 10 ** 10
while ok - ng > 1:
    mid = (ok + ng) >> 1
    if c(mid):
        ok = mid
    else:
        ng = mid
print(ok)
### BUGGY CODE ###

mod = 10 ** 9 + 7

N = int(input())
A = tuple(map(int, input().split()))

ans = 0
for i in range(60):
    cnt = sum((A_i >> i) & 1 for A_i in A)
    ans += (1 << i) * cnt * (N - cnt)

print(ans % mod)

### FIXED CODE ###

def solve():
    import numpy as np
    from sys import stdin
    f_i = stdin
    
    mod = 10 ** 9 + 7
    
    N = int(f_i.readline())
    A = np.array(f_i.readline().split(), dtype=np.int64)
    
    ans = 0
    for i in range(60):
        cnt = np.count_nonzero((A >> i) & 1)
        ans += (1 << i) * cnt * (N - cnt)
    
    print(ans % mod)

solve()
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
c = [0]
for i in range(k):
  b = a[b]-1
  if b in c:
    d = c.index(b)
    e = i-d+1
    k = k - len(c)+e
    c = c[-e:]
    print(c[k%e]+1)
    exit(0)
  else:
    c.append(b)
print(b+1)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split())) 
b = 0
if k<=n:
  for i in range(k):
    b = a[b]-1
  print(b+1)
  exit(0)
c = [0]
for i in range(n):
  b = a[b]-1
  c.append(b)
d = c[:-1].index(c[-1])
c = c[d:-1]
k = k-d
print(c[k%len(c)]+1)
### BUGGY CODE ###

n, m = map(int, input().split())
for i in range(m // n + 1)[::-1]:
  if m % i == 0:
    print(i)
    break

### FIXED CODE ###

def f():
  n, m = map(int, input().split())
  for i in range(m//n+1)[::-1]:
    if m%i==0:return i
print(f())
### BUGGY CODE ###

a, b = map(int, input().split())
common = []
for i in range(1, min(a, b) + 1):
    if a % i == 0 and b % i == 0:
        common.append(i)

count = 1
for i in range(1, len(common)):
    for j in range(2, common[i]):
        if common[i] % j == 0:
            break
    else:
        count += 1
print(count)


### FIXED CODE ###

import fractions
import math
a, b = map(int, input().split())
greatest = fractions.gcd(a, b)

factor = [1]
max_iter = int(math.sqrt(greatest)) + 1
for i in range(2, max_iter):
    while greatest % i == 0:
        greatest //= i
        factor.append(i)
if greatest != 1:
    factor.append(greatest)
factor = set(factor)
print(len(factor))
### BUGGY CODE ###

# coding: utf-8
import sys

ans = str(input())
n = int(input())
r = 2

for i in range(n) :
    x = input().split(" ")
    if int(x[0]) == 1 :
        r = r + 1
    else :
        pp = int(x[1])
        if r % 2 == 1 :
            pp = pp + 1
        if pp % 2  == 1 :
            ans = str(x[2]) + ans
        else :
            ans = ans + str(x[2])

if r % 2 == 1 :
    ans = ans[::-1]

print(ans)

### FIXED CODE ###

# coding: utf-8
import sys
from collections import deque
 
ans = str(input())
n = int(input())
r = 2
be=deque()
af=deque()
 
for i in range(n) :
    x = input().split(" ")
    if int(x[0]) == 1 :
        r = r + 1
    else :
        pp = int(x[1])
        if r % 2 == 1 :
            pp = pp + 1
        if pp % 2  == 1 :
            be.appendleft(str(x[2]))
        else :
            af.append(str(x[2]))

ans = ''.join(be) + ans + ''.join(af)
if r % 2 == 1 :
    ans = ans[::-1]

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

N = int(input())
S = input().rstrip('#').lstrip('.')
intS = []
def xor(A,B):
    #print(A)
    #print(B)
    num = 0
    for a,b in zip(A,B):
        if a^b :
            num = num + 1
    return num
for s in S :
    intS.append(0 if s=='.' else 1)
minC = N

for i in range(len(intS) + 1):
    tmp = [0 for j in range(i)]
    tmp2 = [1 for k in range(len(intS)+1-i)]
    #print(tmp,tmp2)
    tmp = tmp + tmp2
    c = xor(tmp,intS)
    if c < minC:
        minC = c

print(minC)
# def dl(_S):
    

#     l = '.'
#     r = '#'
    
#     _S = _S.lstrip(l).rstrip(r)
#     print(_S)
#     if len(_S) == 0:
#         return 0
#     _S2W = _S.lstrip(r)
#     _S2B = _S.rstrip(l)
#     _S2 =  _S2W if len(_S2W) <= len(_S2B) else _S2B
#     return len(_S) - len(_S2) + dl(_S2)
# print(dl(S))






### FIXED CODE ###

_ = input()
S = input()
numc = S.count('.')
numcmin = numc
for s in S:
    if s == '#':
        numc = numc + 1
    else:
        numc = numc -1
        if numc < numcmin:
            numcmin = numc
print(numcmin)
### BUGGY CODE ###

def solve():
    from bisect import bisect_left

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        B = [x & mask for x in B]
        B.sort()
        bit = 0
        for a in A:
            a_ = a & mask
            T1 = bisect_left(B, T - a_)
            T2 = bisect_left(B, 2 * T - a_)
            T3 = bisect_left(B, 3 * T - a_)
            T4 = bisect_left(B, 4 * T - a_)
            bit += (T4 - T3) + (T2 - T1)
            bit &= 1
        ans += bit * (1 << k)
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    # from bisect import bisect_left
    import sys

    N = int(input())
    A = [int(x) for x in sys.stdin.readline().split()]
    B = [int(x) for x in sys.stdin.readline().split()]
    M = max(A) + max(B)
    K = len(bin(M)) - 2
    mask = (1 << K) - 1
    k = K - 1
    T = 1 << k
    ans = 0
    while k >= 0:
        for i in range(N):
            B[i] &= mask
            A[i] &= mask
        B = list(sorted(b & mask for b in B))
        A = list(sorted(a & mask for a in A))
        bit = 0
        T1, T2, T3 = 0, 0, 0
        for a in reversed(A):
            while T1 < N and a + B[T1] < T:
                T1 += 1
            while T2 < N and a + B[T2] < 2 * T:
                T2 += 1
            while T3 < N and a + B[T3] < 3 * T:
                T3 += 1
            # T1 = bisect_left(B, T - a, T1)
            # T2 = bisect_left(B, 2 * T - a, T2)
            # T3 = bisect_left(B, 3 * T - a, T3)
            # T4 = bisect_left(B, 4 * T - a, T4)
            bit += (N - T3) + (T2 - T1)
            bit &= 1
        ans += bit * T
        k -= 1
        T >>= 1
        mask >>= 1

    print(ans)


if __name__ == '__main__':
    solve()