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

def LS():
    return list(input().split())


S = input()
Q = int(input())
rev = 0
for i in range(Q):
    A = LS()
    if A[0] == "1":
        rev += 1
        rev %= 2
    else:
        if A[1] == "1":
            if rev == 0:
                S = A[2]+S
            else:
                S = S+A[2]
        else:
            if rev == 0:
                S = S+A[2]
            else:
                S = A[2]+S
if rev == 0:
    ans = S
else:
    ans = S[::-1]
print(ans)

### FIXED CODE ###

from collections import deque
S = deque(input())
Q = int(input())
reverse = 0
Tlist = []
for i in range(Q):
    Tlist.append(list(input().split()))
    if Tlist[i][0] == str(2):
        if (int(Tlist[i][1])+reverse) % 2 == 0:
            S.append(Tlist[i][2])
        else:
            S.appendleft(Tlist[i][2])
    else:
        if reverse == 1:
            reverse = 0
        else:
            reverse = 1
if reverse == 0:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))
### BUGGY CODE ###

import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    A = [int(sys.stdin.buffer.readline().rstrip()) for _ in range(M)]

    ret = [0, 1]
    for i in range(1, N + 1):
        if i in A:
            ret.append(0)
        else:
            ret.append((ret[-1] + ret[-2]) % MOD)

    print(ret[-1] % MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    A = set([int(sys.stdin.buffer.readline().rstrip()) for _ in range(M)])

    ret = [0, 1]
    for i in range(1, N + 1):
        if i in A:
            ret.append(0)
        else:
            ret.append((ret[-1] + ret[-2]) % MOD)

    print(ret[-1] % MOD)


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

from functools import lru_cache, reduce
from operator import xor


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


# 右の箱から順に詰める
@lru_cache(maxsize=None)
def f(i):
    return reduce(
        xor,
        (f(j) for j in range(2 * i, N + 1, i)),
        a[i - 1]
    )


b = [i for i in reversed(range(1, N + 1)) if f(i)]
ans = (
    '0' if len(b) == 0 else
    '{}\n{}'.format(
        len(b),
        ' '.join(map(str, b))
    )
)

print(ans)


### FIXED CODE ###

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

b = [0 for _ in range(N + 1)]
M = 0
for i in range(N, 0, -1):
    x = a[i - 1]
    for j in range(i, N + 1, i):
        x += b[j]
    x = x % 2
    b[i] = x
    M += x
print(M)
for i in range(1, N + 1):
    if b[i] == 1:
        print(i)
### BUGGY CODE ###

S = input()
dp = [[0]*13 for i in range(len(S)+1)]
MOD = 10**9+7

dp[0][0] = 1

for i, c in enumerate(S[::-1], 1):
    t = (10 ** (i-1)) % 13
    for j in range(13):
        if c == "?":
            for k in range(10):
                nj = (k*t+j) % 13
                dp[i][nj] += dp[i-1][j]
                dp[i][nj] %= MOD
        else:
            nj = (int(c)*t+j) % 13
            dp[i][nj] += dp[i-1][j]
            dp[i][nj] %= MOD
print(dp[-1][5])

### FIXED CODE ###

from sys import stdin
S = (stdin.readline().rstrip())
dp = [[0]*13 for i in range(len(S)+1)]
MOD = 10**9+7
 
S = list(reversed(S))
dp[0][0] = 1
 
t = 1
for i, c in enumerate(S, 1):
    for j in range(13):
        if c == "?":
            for k in range(10):
                nj = (k*t+j) % 13
                dp[i][nj] = dp[i][nj] + dp[i-1][j]
                dp[i][nj] %= MOD
        else:
            nj = (int(c)*t+j) % 13
            dp[i][nj] = dp[i][nj] + dp[i-1][j]
            dp[i][nj] %= MOD
    t = (t*10)%13
print(dp[-1][5])
### BUGGY CODE ###

R,G,B,N = map(int,input().split())

ans = 0

for r in range(N//R + 1) :
    for g in range((N-r)//G + 1) :
        calc = r*R + g*G
        
        if (N-calc) < 0 :
            break
        
        if (N-calc) % B == 0 :
            ans += 1
print(ans)


### FIXED CODE ###

R,G,B,N = map(int,input().split())

ans = 0


for r in range(N+1) :
    
    for g in range(N+1) :
        if (N - (r*R + g*G)) < 0 : continue
        if (N - (r*R + g*G)) % B == 0 :
            ans += 1
            #print(r,g)
print(ans)
### BUGGY CODE ###

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

# 隣接リスト
A = [[] for _ in range(N)]
# 根
root = -1
R = [True]*N

for i in range(N-1+M):
    a,b = map(int,input().split())
    # a -> b
    A[a-1].append(b-1)
    # a -> b のため、bには親がいる
    R[b-1] = False

# 親判定
for i in range(N):
    if R[i]:
        root = i
        break

# 出力すべき木の親を確定させる
P = [-1]*N
P[root] = -1

from collections import deque
Q = deque([root])
while Q!=deque([]):
    tmpQ = deque([])
    for q in Q:
        for i in A[q]:
            # 親の更新
            P[i] = q
            # 自身をtmpQに
            tmpQ.append(i)
    Q = tmpQ

for i in range(N):
    print(P[i]+1)





### FIXED CODE ###

N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for _ in range(N-1+M)]

A = [[] for _ in range(N)]
P = [0]*N
C = [0]*N
root = -1

for (a,b) in AB:
    # a -> b
    A[a-1].append(b-1)
    C[b-1] += 1

for i in range(N):
    if C[i]==0:
        root = i
P[root] = -1

from collections import deque
que = deque((a,root) for a in A[root])
while que:
    n,par = que.popleft()
    C[n] -= 1
    if C[n]==0:
        P[n] = par
        for i in A[n]:
            que.append((i,n))

for p in P:
    print(p+1)
### BUGGY CODE ###

n,P = map(int,input().split())
#i = 2
from collections import defaultdict
dic = defaultdict(int)
# 約数分解
if n == 1:
    print(P)
    exit()
i = 2
N = P
while i*i <= N:
    if N%i != 0:
        continue
    num = 0
    while N%i == 0:
        num += 1
        N//=i
    dic[i] = num
if N != 1:
    dic[N] = 1
ans = 1
for k,v in dic.items():
    if v//n >= 1:
        ans *= k ** (v//n)
print(ans)


### FIXED CODE ###

n,P = map(int,input().split())
#i = 2
from collections import defaultdict
dic = defaultdict(int)
# 約数分解
if n == 1:
    print(P)
    exit()
i = 2
N = P
while i*i <= N:
    #print(i,N)
    if N%i != 0:
        i += 1
        continue
    num = 0
    while N%i == 0:
        num += 1
        N//=i
    dic[i] = num
    i += 1
if N != 1:
    dic[N] = 1
ans = 1
for k,v in dic.items():
    if v//n >= 1:
        ans *= k ** (v//n)
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
light=list(map(int,input().split()))

for k in range(K):
  copy=[0]*N
  for i in range(N):
    kido=light[i]
    smin=max(0,i-kido)
    smax=min(N-1,i+kido)
    for j in range(smin, smax+1):
      copy[j]+=1
  light=copy
print(*light)

### FIXED CODE ###

N,K=map(int,input().split())
light=list(map(int,input().split()))
for k in range(K):
  imo=[0]*(N+1)
  for i in range(N):
    l=max(0,i-light[i])
    r=min(N-1,i+light[i])+1
    imo[l]+=1
    imo[r]-=1
  for i in range(1,N):
    imo[i]+=imo[i-1]
  if light==imo:
    break
  else:
    light=imo[:]
print(*light[:-1])
### BUGGY CODE ###

N,M=map(int, input().split())
import sys
def input(): return sys.stdin.readline().strip()
A=list(map(int, input().split()))
BC=[list(map(int,input().split())) for i in range(M)]
A.sort()
BC.sort(key=lambda x: x[1],reverse=True)
from bisect import bisect_left
ans=0
numans=0
for m in range(M):
    r=bisect_left(A,BC[m][1])
    if r:
        num=min(r,BC[m][0])
        ans=ans+sum(A[r:])+BC[m][1]*num
        numans+=len(A[r:])+num
        A=A[num:r]
    else:
        break
ans+=sum(A[-(N-numans):])
print(ans)

### FIXED CODE ###

N,M=map(int, input().split())
import sys
def input(): return sys.stdin.readline().strip()
A=list(map(int, input().split()))
BC=[list(map(int,input().split())) for i in range(M)]
A.sort()
BC.sort(key=lambda x: x[1],reverse=True)
from bisect import bisect_left
ans=0
l=0
for m in range(M):
    if BC[m][0]<len(A)-l and A[BC[m][0]+l]<BC[m][1]:
        ans=ans+BC[m][1]*BC[m][0]
        l+=BC[m][0]
    else:     
        r=bisect_left(A[l:],BC[m][1])
        if r:
            ans=ans+BC[m][1]*r
            l+=r
        break
ans+=sum(A[l:])
print(ans)
### BUGGY CODE ###

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
C = Counter(A)

# memo[i][j][k] := 1個残りがi個、2個残りがj個、3個残りがk個である状態にするまでの操作回数の期待値
memo = list3d(N+1, N+1, N+1, -1)
def rec(i, j, k):
    if memo[i][j][k] != -1:
        return memo[i][j][k]
    # 全て残0なら残り回数は0
    if i == j == k == 0:
        return 0
    # 今現在残っている皿を取る確率
    tmp = (i + j + k) / N
    # そのために必要な回数
    res = 1 / tmp
    # それ以降に必要な回数
    if i: res += (i/N) / tmp * rec(i-1, j, k)
    if j: res += (j/N) / tmp * rec(i+1, j-1, k)
    if k: res += (k/N) / tmp * rec(i, j+1, k-1)
    memo[i][j][k] = res
    return res

print(rec(C[1], C[2], C[3]))


### FIXED CODE ###

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
C = Counter(A)

# dp[i][j][k] := 3個残りがi個、2個残りがj個、1個残りがk個である状態にするまでの操作回数の期待値
dp = list3d(N+1, N+1, N+1, INF)
# 全て残0なら残り回数は0
dp[0][0][0] = 0.0
for i in range(N+1):
    for j in range(N+1):
        # 枝刈り
        if i+j > N:
            break
        for k in range(N+1):
            # 枝刈り
            if i+j+k > N:
                break
            if i == j == k == 0:
                continue
            # 今現在残っている皿を取る確率
            tmp = (i + j + k) / N
            # そのために必要な回数
            res = 1 / tmp
            # それ以降に必要な回数
            if i and j < N: 
                res += (i/N) / tmp * dp[i-1][j+1][k]
            if j and k < N: 
                res += (j/N) / tmp * dp[i][j-1][k+1]
            if k: 
                res += (k/N) / tmp * dp[i][j][k-1]
            dp[i][j][k] = res
print(dp[C[3]][C[2]][C[1]])
### BUGGY CODE ###

from math import factorial

n=int(input())
a=sorted(map(int, input().split()), reverse=True)

def C(n, r):
	return factorial(n) // factorial(r) // factorial(n-r)

ix = 1
vx = C(a[0], a[1])

for i in range(1, n):
	if vx < C(a[0], a[i]):
		ix = i
		vx = C(a[0], a[i])

print("%d %d" % (a[0], a[ix]))


### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
b=max(a)
_,c=min([(abs(b/2-x), x) for x in a])
print("%d %d" % (b, c))
### BUGGY CODE ###

def resolve():
    from collections import deque
    n, m = map(int, input().split())
    michi=s = [[0 for i in range(n)] for j in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        michi[a-1][b-1]=1
        michi[b - 1][a - 1] = 1
    heya=[-1]*n

    def f():
        check=0
        que = deque([])
        que.append(0)
        while que:
            if check==n:
                break
            else:
                p=que.popleft()
                for i in range(n):
                    if michi[p][i]==1 and heya[i]==-1:
                        michi[p][i]=0
                        heya[i]=p+1
                        check+=1
                        que.append(i)
        return

    f()
    print("Yes")
    for i in heya[1:]:
        print(i)
resolve()

### FIXED CODE ###

def resolve():
    from collections import deque
    n, m = map(int, input().split())
    michi = [[] for j in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        michi[a-1].append(b-1)
        michi[b - 1].append(a - 1)
    heya=[-1]*n

    def f():
        check=0
        que = deque([])
        que.append(0)
        while que:
            p = que.popleft()
            for i in michi[p]:
                if heya[i] == -1:
                    heya[i] = p + 1
                    check += 1
                    if check == n :
                        break
                    que.append(i)

        return

    f()
    print("Yes")
    for i in heya[1:]:
        print(i)
resolve()
### BUGGY CODE ###

import bisect

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

for i in range(M):
    B, C = map(int,input().split())
    index = bisect.bisect_left(A,C)
    if B < index :
        A = [C] * (B) + A[B:]
    else:
        A = [C] * (index) + A[index:]
    A.sort()
print(sum(A))

### FIXED CODE ###

import bisect
import itertools

N, M  = map(int,input().split())
A = sorted(list(map(int,input().split())))
D = []

for i in range(M):
    B, C = map(int,input().split())
    D.append((B,C))

D.sort(key = lambda x:x[1],reverse = True)

cnt = 0
ans = []
for b, c in D:
    for i in range(b):
        ans.append(c)
    cnt += b
    if cnt >=N:
        break
#print(D)
#print(ans)
res = sum(A)
for i in range(min(N,len(ans))):
    if ans[i]-A[i]>0:
        res += ans[i] - A[i]
    else:
        break
print(res)
### BUGGY CODE ###

class Combination:
    def __init__(self, size, MOD):
        self.MOD = MOD
        self.size = size + 2

        f = 1
        self.fact = fact = [f]
        for i in range(1, size+1):
            f = f * i % MOD
            fact.append(f)
        f = pow(f, MOD-2, MOD)
        self.factInv = factInv = [f]
        for i in range(size, 0, -1):
            f = f * i % MOD
            factInv.append(f)
        factInv.reverse()

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.MOD) % self.MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

def sol():
    K = int(input())
    N = len(input())
    MOD = 10**9 + 7
    comb = Combination(N + K + 10, MOD)

    ans = 0
    for l in range(K + 1):
        r = K - l
        ans += comb.nhr(N, l) * pow(25, l, MOD) * pow(26, r, MOD)
    print(ans % MOD)
sol()

### FIXED CODE ###

MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

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

comb = Combination(N + K + 100)

ans = 0
for l in range(K + 1):
    r = K - l
    ans += pow(25, l, MOD) * comb.nhr(N, l) * pow(26, r, MOD)
    ans %= MOD

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

from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(M):
    data.append(int(input()))

ans = [1] + [0] * (N)
for i in range(1,N + 1):
    if i == 1:
        if 1 in data:
            ans[1] = 0
        else:
            ans[1] = 1
    else:
        if i in data:
            ans[i] = 0
        else:
            ans[i] = ans[i-1] + ans[i-2]
print(ans[-1] % 1000000007)

### FIXED CODE ###

from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = [0] * M
for _ in range(M):
    data[_] = (int(stdin.readline().rstrip()))
 
ans = [1] + [0] * (N)
for i in (set(range(1,N+1)) - set(data)):
    ans[i] = ans[i-1] + ans[i-2]
print(ans[-1] % 1000000007)
### BUGGY CODE ###

N,Q = (int(i) for i in input().split()) 
S = input()
ans = []

for i in range(Q):
	l, r = (int(i) for i in input().split())
	ans.append(S[l-1 : r].count("AC"))

for i in range(len(ans)):
	print(ans[i])

### FIXED CODE ###

n,q=map(int,input().split())
s=input()

accumlate=[0]
now=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        now+=1
    accumlate.append(now)

ans_list=[]
for g in range(q):
    l,r=map(int,input().split())
    ans_list.append(accumlate[r-1]-accumlate[l-1])

for m in range(q):
    print(ans_list[m])
### BUGGY CODE ###

import numpy as np
from itertools import product

n = int(input())
s = np.array([int(input()) for _ in range(n)])

ans = set([0])
for i in product((0, 1), repeat=n):
    x = sum(np.array(i) * s)
    if x % 10 != 0:
        ans.add(x)
print(max(ans))

### FIXED CODE ###

s = [int(input()) for _ in range(int(input()))]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i, x in enumerate(s):
        if x % 10 != 0:
            print(sum(s) - x)
            break
    else:
        print(0)
### BUGGY CODE ###

import bisect

n = int(input())
l = sorted([int(i) for i in input().split()])
ans = 0
for i in range(1,n-1):
    for j in range(i+1,n):
        if i - bisect.bisect_right(l,(l[j]-l[i])) > 0:
            ans += i - bisect.bisect_right(l,(l[j]-l[i]))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
l = sorted([int(i) for i in input().split()])
ans = 0
for i in range(1,n-1):
    tmp=0
    for j in range(i+1,n):
        if l[j] - l[i] >= l[i-1]:
            break
        else:
            for k in range(tmp,i):
                if l[tmp] > l[j]-l[i]:
                    ans += i-tmp
                    break
                elif l[k] > l[j]-l[i]:
                    tmp = k
                    ans += i-tmp
                    break
print(ans)
### BUGGY CODE ###

n, k, q = map(int, input().split(' '))
scores = [k for i in range(n)]
for i in range(q):
    a = int(input())
    for j in range(n):
        scores[j] -= 1
    scores[a-1] += 1
for i in range(n):
    if scores[i] > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

n, k, q = map(int, input().split(" "))
liste = [(k-q) for i in range(n)]
for i in range(q):
    a = int(input())
    liste[a-1] += 1
for i in liste:
    if i > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import math
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            x=math.gcd(a,b)
            ans+=math.gcd(x,c)
print(ans)

### FIXED CODE ###

from math import gcd
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcd(gcd(a,b),c)
print(ans)
### BUGGY CODE ###

import sys

p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=[[int(c) for c in SI()] for _ in range(n-1)]
    #p2D(aa)

    dp=set()
    dp.add((1<<n)-1)
    for _ in range(n-1):
        ndp=set()
        for bit in dp:
            i=j=(bit&-bit).bit_length()-1
            while 1<<i<bit:
                i+=1
                while bit>>i&1==0 and 1<<i<=bit:i+=1
                if 1<<i>bit:break
                if aa[i-1][j]:nbit=bit^1<<j
                else:nbit=bit^1<<i
                ndp.add(nbit)
                j=i
        dp=ndp

    print(len(dp))

main()

### FIXED CODE ###

import sys

p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline()[:-1]
def pbit(aa,L):
    for a in aa:print(format(a,"b").zfill(L))
    print()

def main():
    n=II()
    aa=[[int(c) for c in SI()] for _ in range(n-1)]
    #p2D(aa)
    
    # 人iが勝てる相手をbitで管理する
    win=[0]*n
    for i,row in enumerate(aa,1):
        for j,a in enumerate(row):
            if a:win[i]|=1<<j
            else:win[j]|=1<<i
    #pbit(win,n)

    # dpl[i]...[j,i]の範囲で優勝できるjをbitで
    # dpr[i]...[i,j]の範囲で優勝できるjをbitで
    dpl=[1<<i for i in range(n)]
    dpr=[1<<i for i in range(n)]
    for d in range(1,n):
        for i in range(n):
            j=i+d
            if j<n and dpl[j] & dpr[i+1] & win[i]:dpl[j]|=1<<i
            j=i-d
            if j>=0 and dpl[i-1] & dpr[j] & win[i]:dpr[j]|=1<<i
    #pbit(dpl,n)
    #pbit(dpr,n)
    #print(format(dpl[n-1]&dpr[0],"b").zfill(n))
    print(bin(dpl[n-1]&dpr[0]).count("1"))

main()
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def inv(a):
    n = mod - 2
    r = 1
    while n > 0:
        if n % 2 == 1:
            r = r * a % mod
        a = a * a % mod
        n >>= 1
    return r

def nCb(n, b):
    if b > n - b:
        b = n - b
    r = 1
    for k in range(n, n-b, -1):
        r = r * k % mod
    d = 1
    for k in range(1, b+1):
        d = d * k % mod
    return r * inv(d) % mod


def main():
    n = I()
    a = LI_()
    b = [-1] * n
    t = 1
    for i in range(n+1):
        c = a[i]
        if b[c] >= 0:
            t = i - b[c]
            break
        b[c] = i

    rr = [n]
    for i in range(2,n+2):
        tr = nCb(n+1,i)
        if n-t >= i-1:
            tr -= nCb(n-t, i-1)
            tr %= mod
        rr.append(tr)
    return '\n'.join(map(str, rr))

print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def M(n): return ModInt(n)
def MI(): return M(I())

class ModInt():
    def __init__(self, n):
        self.n = n

    def __add__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n+x) % mod)

    def __sub__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n-x) % mod)

    def __mul__(self, x):
        x = ModInt.xn(x)
        return ModInt((self.n*x) % mod)

    def __truediv__(self, x):
        x = ModInt.xn(x)
        return ModInt(self.n * pow(x, mod-2, mod) % mod)

    @classmethod
    def xn(cls, x):
        if isinstance(x, ModInt):
            return x.n
        return x

    def __str__(self):
        return str(self.n)

def main():
    n = I()
    a = LI_()
    b = [-1] * n
    t = 1
    for i in range(n+1):
        c = a[i]
        if b[c] >= 0:
            t = i - b[c]
            break
        b[c] = i

    rr = [n]
    nb = M(n+1)
    nt = M(1)
    for i in range(2,n+2):
        nb *= n-i+2
        nb /= i

        tr = nb.n
        if n-t >= i-1:
            nt *= n-t-i+2
            nt /= i-1
            tr -= nt.n
            tr %= mod
        rr.append(tr)
    return '\n'.join(map(str, rr))

print(main())