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

N=int(input())
for m in range(N):
  n=m+1
  f=0
  for x in range(1,n+1):
    if x*x>=n:
      break
    for y in range(1,n+1):
      if x*x+y*y>=n:
        break
      for z in range(1,n+1):
        if x*x + y*y + z*z >=n:
          break
        t=x**2 + y**2 + z**2 + x*y + y*z + z*x
        if t==n:
          f += 1
  print(f)

### FIXED CODE ###

N=int(input())
a=[]
for i in range(N):
  a.append(0)
for x in range(1,N+1):
  if x**2>=N:
    break
  for y in range(1,N+1):
    if x**2 + y**2 >= N:
      break
    for z in range(1,N+1):
      if x**2+y**2+z**2>=N:
        break
      t=x**2+y**2+z**2+x*y+y*z+z*x
      if t<=N:
        a[t-1] += 1
for m in range(N):
  print(a[m])
### BUGGY CODE ###

N = int(input())
A = list(int(input())for i in range(N))
H = [float('inf'),A[0]]
for i in range(1,N):
    if A[i] <= H[-1]:
        H.append(A[i])
    else:
        for j in range(len(H)-1,-1,-1):
            if H[j] >= A[i]:
                H[j+1] = A[i]
                break
print(len(H)-1)



### FIXED CODE ###

N = int(input())
A = list(int(input())for i in range(N))
H = [A[0]]
for i in range(1,N):
    if A[i] <= H[-1]:
        H.append(A[i])
    else:
        l,r =0,len(H)
        while l != r :
            if H[(l+r)//2]>=A[i]:
                l = (l+r)//2+1
            else:
                r = (l+r)//2
        H[l] = A[i]
print(len(H))
### BUGGY CODE ###

from functools import reduce 

ans=1
a,b=map(int,input().split())
if a<0 and b>0:
    print ("Zero")
else:
    ans=reduce((lambda x, y: x * y), range(a,b+1)) 
    if ans>0:
        print ("Positive")
    else:
        print ("Negative")

### FIXED CODE ###

a,b=map(int,input().split())
if a<=0<=b:
    print ("Zero")
elif (min(0,b)-a)%2:
    print ("Positive")
else:
    print ("Negative")
### BUGGY CODE ###

import itertools

n, a = map(int, input().split())
integers = list(int(x) - a for x in input().split())
count = 0
for i in range(1, len(integers)+1):
    for combs in itertools.combinations(integers, i):
        av = sum(combs) / i
        if av == 0:
            count += 1

print(count)


### FIXED CODE ###

import sys

n, a, *x = map(int, sys.stdin.read().split())

def main():
    ma = a * n
    res = [[[0] * (ma + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    res[0][0][0] = 1
    for i in range(n):
        cur = x[i]
        for j in range(i+2):
            for k in range(ma + 1):
                res[i+1][j][k] += res[i][j][k]
                if k >= cur:
                    res[i+1][j][k] += res[i][j-1][k-cur]
    
    ans = 0
    for j in range(1, n+1):
        ans += res[n][j][j*a]

    return ans

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

from sys import stdin
from bisect import insort


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(x) for x in stdin.readline().rstrip().split()]
    As.sort()
    for _ in range(M):
        x = As[-1] / 2
        insort(As, x)
        del As[-1]
    sum_ = 0
    for x in As:
        sum_ += int(x)
    print(sum_)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
import heapq


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    As = []
    for i in [int(x) for x in stdin.readline().rstrip().split()]:
        heapq.heappush(As, -i)
    for _ in range(M):
        x = heapq.heappop(As)
        heapq.heappush(As, x / 2)
    print(sum([-1 * int(x) for x in As]))


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

str1 = [s for s in input()]
str2 = [s for s in input()]

dp = [[0 for _ in range(len(str2) + 1)] for _ in range(len(str1) + 1)]

for i in range(len(str1)):
    for j in range(len(str2)):
        dp[i + 1][j + 1] = max(dp[i][j+1],dp[i+1][j])
        if str1[i] == str2[j]:
            newVal = max(dp[i + 1][j + 1] ,dp[i][j] + 1)
            dp[i + 1][j + 1] = newVal

result = ""

i = len(str1)
j = len(str2)

while i >= 0 and j >= 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    elif dp[i][j] != dp[i -1][j - 1]:
        result += str1[i -1]
        i -= 1
        j -= 1

print(result[::-1])

### FIXED CODE ###

str1 = [s for s in input()]
str2 = [s for s in input()]

dp = [[0 for _ in range(len(str2) + 1)] for _ in range(len(str1) + 1)]

for i in range(len(str1)):
    for j in range(len(str2)):
        dp[i + 1][j + 1] = max(dp[i][j+1],dp[i+1][j])
        if str1[i] == str2[j]:
            newVal = max(dp[i + 1][j + 1] ,dp[i][j] + 1)
            dp[i + 1][j + 1] = newVal

result = ""

i = len(str1)
j = len(str2)

while i >= 0 and j >= 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    elif dp[i][j] != dp[i -1][j - 1]:
        result += str1[i -1]
        i -= 1
        j -= 1

print(result[::-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import numpy as np

MOD = 10 ** 9 + 7
N = int(input())

graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    x,y = map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)

"""
包除の原理。各頂点を根として
・偶数個を選ぶ、そこが反例となっている、他は何でもよい、
・奇数個を選ぶ、そこが反例となっている、他は何でもよい
・根を含む成分は保留してある。保留している頂点の数を持っておく。
・偶数個の場合と奇数の場合の差分だけ持っておく
"""

def dp_merge(data1,data2):
    N1 = len(data1) - 1
    N2 = len(data2) - 1
    data = np.zeros(N1+N2, dtype = np.int64)
    for n in range(1,N1+1):
        data[n:n+N2] += data1[n] * data2[1:] % MOD
    data %= MOD
    return data

fact_2 = [1,0,1]
for n in range(3,N+10):
    fact_2.append(fact_2[n-2] * (n-1) % MOD)
fact_2 = np.array(fact_2, dtype = np.int64)

def dp_add_edge(data):
    N = len(data) - 1
    data1 = np.zeros(N+2, dtype=np.int64)
    # 辺を反例に加えない
    data1[1:] = data
    # 辺を反例に加える
    data1[1] = - (data * fact_2[:N+1] % MOD).sum() % MOD
    return data1

def dfs(v, parent = None):
    data = None
    for y in graph[v]:
        if y == parent:
            continue
        data1 = dfs(y, v)
        # mergeする前に、最後の辺をひとつ加える
        data1 = dp_add_edge(data1)
        if data is None:
            data = data1
        else:
            data = dp_merge(data, data1)
    if data is None:
        return np.array([0,1],dtype=np.int64)
    return data

data = dfs(1)

answer = (data * fact_2[:N+1] % MOD).sum() % MOD

print(answer)

arr = np.arange(5)
arr

np.roll(arr,2)



### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
import numpy as np

MOD = 10 ** 9 + 7
N = int(input())

graph = [[] for _ in range(N+1)]
for _ in range(N-1):
    x,y = map(int,input().split())
    graph[x].append(y)
    graph[y].append(x)

"""
包除の原理。各頂点を根として
・偶数個を選ぶ、そこが反例となっている、他は何でもよい、
・奇数個を選ぶ、そこが反例となっている、他は何でもよい
・根を含む成分は保留してある。保留している頂点の数を持っておく。
・偶数個の場合と奇数の場合の差分だけ持っておく
"""

def dp_merge(data1,data2):
    N1 = len(data1) - 1
    N2 = len(data2) - 1
    if N1 > N2:
        N1,N2 = N2,N1
        data1,data2 = data2,data1
    data = np.zeros(N1+N2, dtype = np.int64)
    for n in range(1,N1+1):
        data[n:n+N2] += data1[n] * data2[1:] % MOD
    data %= MOD
    return data

fact_2 = [1,0,1]
for n in range(3,N+10):
    fact_2.append(fact_2[n-2] * (n-1) % MOD)
fact_2 = np.array(fact_2, dtype = np.int64)

def dp_add_edge(data):
    N = len(data) - 1
    data1 = np.zeros(N+2, dtype=np.int64)
    # 辺を反例に加えない
    data1[1:] = data
    # 辺を反例に加える
    data1[1] = - (data * fact_2[:N+1] % MOD).sum() % MOD
    return data1

def dfs(v, parent = None):
    data = None
    for y in graph[v]:
        if y == parent:
            continue
        data1 = dfs(y, v)
        # mergeする前に、最後の辺をひとつ加える
        data1 = dp_add_edge(data1)
        if data is None:
            data = data1
        else:
            data = dp_merge(data, data1)
    if data is None:
        return np.array([0,1],dtype=np.int64)
    return data

data = dfs(1)

answer = (data * fact_2[:N+1] % MOD).sum() % MOD

print(answer)
### BUGGY CODE ###

from collections import deque

def main():
    S = deque(input())
    Q = int(input())
    for _ in range(Q):
        query = input().split()
        if query[0] == "1":
            S.reverse()
            continue
        if query[1] == "1":
            S.appendleft(query[2])
        else:
            S.append(query[2])
    print("".join(list(S)))
        
if __name__ == "__main__":
    # print(timeit.timeit(lambda: main(), number=1))
    main()


### FIXED CODE ###

from collections import deque

def main():
    S = deque(input())
    Q = int(input())
    rev_flag = False
    for _ in range(Q):
        query = input().split()
        if query[0] == "1":
            rev_flag = not(rev_flag)
            continue
        if query[1] == "1":
            if rev_flag:
                S.append(query[2])
            else:
                S.appendleft(query[2])
        else:
            if rev_flag:
                S.appendleft(query[2])
            else:
                S.append(query[2])
    
    if rev_flag:
        S.reverse()

    print("".join(list(S)))
        
if __name__ == "__main__":
    # print(timeit.timeit(lambda: main(), number=1))
    main()
### BUGGY CODE ###

n = int(input())
a = [input() for hoge in range(n)]
b = sorted(a)
c = set(a)
d = 0
ans = []
for poge in c:
  if d < b.count(poge):
    d = b.count(poge)
for raw in b:
  if d == b.count(raw):
    ans.append(raw)
answer = sorted(set(ans))
for q in answer:
  print(q)

### FIXED CODE ###

import collections
n = int(input())
a = [input() for hoge in range(n)]
counted = collections.Counter(a)
m = max(counted.values())
chars = [key for key, value in counted.items()
             if value == m]
c = sorted(chars)
for poge in c:
  print(poge)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())
info = [[] for _ in range(N+1)] # i -> info[i] 行き先
note = []
for _ in range(M):
    x,y = map(int,input().split())
    info[x].append(y)
    note.append(y)
note = list(set(range(1,N+1)) - set(note))
ans = 0
def dfs(p, length = 0):
    # 行き場所がなければlengthをメモ
    global ans
    if info[p] == [] and length > ans:
        ans = length
    for d in info[p]:
        dfs(d, length + 1)
for i in note:
    dfs(i)
print(ans)

### FIXED CODE ###

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

N,M = map(int,input().split())
ad = [[] for i in range(N)]
for _ in range(M):
    x,y = map(int,input().split())
    x -= 1; y -= 1
    ad[x].append(y)

dp = [-1]*N

def rec(nodes):
    if dp[nodes] != -1:
        return dp[nodes]
    res = 0
    for ne in ad[nodes]:
        option = rec(ne)+1
        if res < option:
            res = option
    dp[nodes] = res
    return dp[nodes]

ans = 0
for i in range(N):
    res = rec(i)
    if ans < res:
        ans = res
print(ans)
### BUGGY CODE ###

import numpy as np
N,K = map(int,input().split())
A=[int(i) for i in input().split()]
F=[int(i) for i in input().split()]
A.sort()
F.sort()
F.reverse()
#print(A)
#print(F)
B = np.array(A)*np.array(F)
#print(B)
for j in range(K):
    max_i = np.argmax(B)
    B[max_i] -= F[max_i]
#print(B)
print(max(B))

### FIXED CODE ###

import sys
import numpy as np
N,K=map(int,input().split())
A=np.array([int(i) for i in input().split()])
F=np.array([int(i) for i in input().split()])
A=np.sort(A)
F=np.sort(F)[::-1]
 
Asum = A.sum()
def test(x):
    return Asum - np.minimum(A,x//F).sum() <= K
 
l=0
r=10**18*2+1
while r-l > 1:
    #print(l,r)
    m = (l+r)//2
    if test(m):
        r=m
    else:
        l=m
if test(l):
    print(l)
else:
    print(l+1)
### BUGGY CODE ###

N= int(input())
A = list(map(int, input().split()))
B=[0]*N
C=0
for i in range(N):
    B[i]=A.count(i+1)
for i in range(N):
    C=C+B[i] * (B[i] - 1) / 2

for i in range(N):
    print(int(C-(B[A[i]-1])+1))

### FIXED CODE ###

import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))
### BUGGY CODE ###

N, M = map(int, input().split())
ab_list = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

lis = [[] for i in range(N)]

for i in range(M):
    lis[ab_list[i][0]].append(ab_list[i][1])

que = [[0, 0, lis[0], []]]
ends = []
res = False

while que:
    count, now, next_nodes, visited = que.pop()
    ends.append(visited)
    visited.append(now)
    for node in next_nodes:
        if node in visited or count == 2:
            continue
        que.append([count + 1, node, lis[node], visited[:]])

print()

if N - 1 in set(sum(ends, [])):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


### FIXED CODE ###

N, M = map(int, input().split())
ab_list = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

lis = [[] for i in range(N)]

for i in range(M):
    lis[ab_list[i][0]].append(ab_list[i][1])

que = [[0, 0, lis[0], []]]
ends = []
res = False

while que:
    count, now, next_nodes, visited = que.pop()
    visited.append(now)
    if now == N - 1:
        ends = visited[:]
    for node in next_nodes:
        if node in visited or count == 2:
            continue
        que.append([count + 1, node, lis[node], visited[:]])

if N - 1 in ends:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

MOD = 10 ** 9 + 7

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

def init(n):
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

def nPk(n, k):
    return fact[n] * factinv[n - k] % MOD

def nCk(n, k):
    return fact[n] * factinv[n - k] * factinv[k] % MOD

def pow(x, n, mod):
    res = 1
    while n:
        if n % 2:
            res = res * x % mod
        x = x * x % mod
        n //= 2
    return res

K = int(input())
N = len(input())

init(N + K)

ans = 0
for m in range(K + 1):
    n = N + K
    ans += pow(25, K - m, MOD) * pow(26, m, MOD) * nCk(n - 1 - m, N - 1) % MOD
print(ans % MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

def init(n):
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)

def nPk(n, k):
    return fact[n] * factinv[n - k] % MOD

def nCk(n, k):
    return fact[n] * factinv[n - k] * factinv[k] % MOD

K = int(input())
N = len(input())

init(N + K)
p25 = [1]
p26 = [1]

for k in range(K):
    p25.append(p25[-1] * 25 % MOD)
    p26.append(p26[-1] * 26 % MOD)

ans = 0
for m in range(K + 1):
    n = N + K
    ans += p25[K - m] * p26[m] * nCk(n - 1 - m, N - 1) % MOD
print(ans % MOD)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Jan  4 20:10:14 2019

@author: Yamazaki Kenichi
"""

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

#P,Y = [input().split() for i in range(M)]
#P = [int(P[i]) for i in range(M)]
#Y = [int(Y[i]) for i in range(M)]

C = [list(map(int,input().split())) for i in range(M)]

counta = [0]*N
a = [[] for i in range(N)]
for j in range(M):
    for i in range(1,N+1):
        if C[j][0] == i:
            counta[i-1] +=1
            a[i-1].append(C[j][1])

for i in range(N):
    a[i].sort()

ans = []
for j in range(M):
        
    l = '0'*(6-len(str(C[j][0])))+str(C[j][0])
    r1 = a[C[j][0]-1].index(C[j][1])+1
    r = '0'*(6-len(str(r1)))+str(str(r1))
    ans = l + r 
    print(ans)



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Jan  4 20:10:14 2019

@author: Yamazaki Kenichi
"""
import bisect

N, M= map(int,input().split())
C = [list(map(int,input().split())) for i in range(M)]

a = [[] for i in range(N)]
for j in range(M):
    a[C[j][0]-1].append(C[j][1])

for i in range(N):
    a[i].sort()

ans = []
for j in range(M):
    l = '0'*(6-len(str(C[j][0])))+str(C[j][0])
    r1 = bisect.bisect_left(a[C[j][0]-1],(C[j][1]))+1
    r = '0'*(6-len(str(r1)))+str(str(r1))
    ans = l + r 
    print(ans)
### BUGGY CODE ###

from heapq import heappush, heappop, merge
from collections import defaultdict

def solve():
    N, Q = map(int, input().split())
    events = []
    for _ in range(N):
        s, t, x = map(int, input().split())
        events.append((s-x, 1, x))
        events.append((t-x, -1, x))
    for _ in range(Q):
        d = int(input())
        events.append((d, 2, d))
    events = sorted(events)

    constructions = []
    under_construction = defaultdict(bool)
    ans = ''
    for _, flag, coord in events:
        if flag == 1:
            heappush(constructions, coord)
            under_construction[coord] = True
        elif flag == -1:
            under_construction[coord] = False
        else:
            while constructions:
                x = heappop(constructions)
                if under_construction[x]: # x is the minimum coordinate under construction
                    heappush(constructions, x)
                    ans += str(x) + '\n'
                    break
            else: # no constructions
                ans += '-1\n'
    print(ans)
    
if __name__ == "__main__":
    solve()

### FIXED CODE ###

from heapq import heappush, heappop, merge
from collections import defaultdict
import sys
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N, Q = map(int, line_input())
    events = []
    for _ in range(N):
        s, t, x = map(int, line_input())
        events.append((s-x, 1, x))
        events.append((t-x, -1, x))
    for _ in range(Q):
        d = int(single_input())
        events.append((d, 2, d))
    events = sorted(events)

    constructions = []
    under_construction = defaultdict(bool)
    ans = ''
    for _, flag, coord in events:
        if flag == 1:
            heappush(constructions, coord)
            under_construction[coord] = True
        elif flag == -1:
            under_construction[coord] = False
        else:
            while constructions:
                x = heappop(constructions)
                if under_construction[x]: # x is the minimum coordinate under construction
                    heappush(constructions, x)
                    ans += str(x) + '\n'
                    break
            else: # no constructions
                ans += '-1\n'
    print(ans)
    
if __name__ == "__main__":
    solve()
### BUGGY CODE ###

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
#mo=998244353
#input=sys.stdin.readline

n=I()
s=input()
ans=0
t=''
l,r=0,0
for i in range(n*2):
    if i==0:
        t+='L'
        l+=1
        continue
    if ((l-r)%2==1 and s[i]=='W') or ((l-r)%2==0 and s[i]=='B'):
        t+='L'
        l+=1
    else:
        t+='R'
        r+=1
if t.count('L')!=n:
    print(0)
    exit()
    
#print(s,t)
L,R=0,0
ans=1
for i in t:
    if i=='L':
        L+=1
    if i=='R':
        ans*=L-R
        ans%=mo
        R+=1
f=1
for i in range(2,n+1):
    f*=i
    f%=mo
print((ans*f)%mo)



### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
#mo=998244353
#input=sys.stdin.readline

n=I()
s=list(input())
ans=0
t=[]
l,r=0,0
for i in range(n*2):
    if i==0:
        t+=['L']
        l+=1
        continue
    if ((l-r)%2==1 and s[i]=='W') or ((l-r)%2==0 and s[i]=='B'):
        t+=['L']
        l+=1
    else:
        t+=['R']
        r+=1
if t.count('L')!=n:
    print(0)
    exit()
    
#print(s,t)
L,R=0,0
ans=1
for i in t:
    if i=='L':
        L+=1
    if i=='R':
        ans*=L-R
        ans%=mo
        R+=1
f=1
for i in range(2,n+1):
    f*=i
    f%=mo
print((ans*f)%mo)
### BUGGY CODE ###

from scipy.misc import comb

MAX = 10**9 + 7

def man_comb(_N, _K):
    if _K > (_N/2):
        return comb(_N, _N - _K, exact=True)
    else:
        return comb(_N, _K, exact=True)

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = M*N* (M*(N+1)*(N-1) + N*(M+1)*(M-1)) / 6
    if disSum >= MAX:
        disSum %= MAX
    ret = disSum * man_comb(M*N-2, K-2)
    if ret >= MAX:
        ret %= MAX
    print ret

if __name__ == '__main__':
    solve()


### FIXED CODE ###

MAX = 10**9 + 7

def mod_inv(i, mod):
    return pow(i, mod-2, mod)

def combination(_N, _K):
    if _K > (_N/2):
        _K = _N - _K
    up = 1
    low = 1
    for i in range (_K):
        up = up * (_N - i) % MAX
        low = low * (i + 1) % MAX
    ret = up * mod_inv(low, MAX) % MAX
    return ret

def solve():
    N, M, K = [int(_) for _ in raw_input().split()]
    disSum = (M*N* ((M*(N+1)*(N-1))%MAX + (N*(M+1)*(M-1)) % MAX)) % MAX
    disSum *= mod_inv(6, MAX) % MAX
    ret = disSum * combination(M*N-2, K-2) % MAX
    print ret

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

x = int(input())
x_mod = x % 5
i = -200
while True:
    if i - (i - x_mod) == x_mod and i ** 5 - (i-x_mod)**5 == x:
        print(i, i-x_mod)
        break
    i += 1

### FIXED CODE ###

x = int(input())

for i in range(-120, 120):
    for j in range(-120, 120):
        if x == i ** 5 - j ** 5:
            print(i, j)
            exit()
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
from collections import Counter
AC = dict(Counter(A))
maxA, maxAcnt = max(AC.items(), key=lambda x: x[1])
BC = dict(Counter(B))
maxB, maxBcnt = max(BC.items(), key=lambda x: x[1])

if maxA==maxB and maxAcnt>=(N+2)//2 and maxBcnt>=(N+2)//2:
    print("No")
else:
    print("Yes")
    outB= [0]*N
    for i in range(N):
        if A[i]==maxA:
            start = i
            break
    from collections import deque
    que = deque(B)
    t = start
    while que:
        v = que.popleft()
        if v==A[t]:
            que.append(v)
        else:
            outB[t]=v
            t+=1
            if t==N:
                t=0
    print(*outB)

### FIXED CODE ###

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

NG = []
for i in range(N):
    if A[i]==Br[i]:
        NG.append(i)
        NGnumber = Br[i]
NGcnt = len(NG)

if NGcnt==0:
    print("Yes")
    print(*Br)
else:
    OK = []
    for i in range(N):
        if Br[i]!=NGnumber and A[i]!=NGnumber:
            OK.append(i)
    OKcnt = len(OK)

    if NGcnt>OKcnt:
        print("No")
    else:
        for i in range(NGcnt):
            Br[NG[i]],Br[OK[i]]=Br[OK[i]],Br[NG[i]]
        print("Yes")
        print(*Br)
### BUGGY CODE ###

s = input()
n = int(input())
q = []
for i in range(n):
  query = list(input().split())
  q.append(query)
  
a = 1
for i in range(n):
  if int(q[i][0]) == 1:
    a *= -1
  else:
    if int(q[i][1]) == 1:
      if a > 0:
        s = q[i][2] + s
      else:
        s = s + q[i][2]
    else:
      if a > 0:
        s = s + q[i][2]
      else:
        s = q[i][2] + s
if a > 0:
  print(s)
else:
  s = s[::-1]
  print(s)
  

### FIXED CODE ###

from collections import deque
s = deque(input())
n = int(input())
q = []
for i in range(n):
  query = list(input().split())
  q.append(query)
  
a = 1
for i in range(n):
  if int(q[i][0]) == 1:
    a *= -1
  else:
    if int(q[i][1]) == 1:
      if a > 0:
        s.appendleft(q[i][2])
      else:
        s.append(q[i][2])
    else:
      if a > 0:
        s.append(q[i][2])
      else:
        s.appendleft(q[i][2])
s = list(s)
s = "".join(s)
if a > 0:
  print(s)
else:
  s = s[::-1]
  print(s)