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

def key(k):
    return (len(k), k)    

def solve(S, K):
    ss = set()
    for k in range(1, len(S)+1): 
        for i in range(0, len(S)-k+1):
            ss.add(S[i:i+k])
    ss = sorted(ss)
    return ss[K-1]
    
S = input().strip()
K = int(input())

print(solve(S, K))


### FIXED CODE ###

S = input()
# 5000
K = int(input())
# K < 5

s = []
for i in range(len(S)):
    for k in range(1,K+1):
        s.append(S[i:i+k])

print(sorted(set(s))[K-1])
### BUGGY CODE ###

import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]

a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])

a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    if a[i][1] in c:
            print("POSSIBLE")
            sys.exit()
        
print("IMPOSSIBLE")


### FIXED CODE ###

import sys
n,m=map(int,input().split())
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]
s=[]
a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])
c=set(c)
a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    else:
        s.append(a[i][1])

    #if a[i][1] in c:
s=set(s)

for i in s:
    if i in c:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")
### BUGGY CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
from functools import lru_cache
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inp_str():
    '''
    一行の文字をlistで取得
    '''
    return list(input())[:-1]
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

class Angle():
    DIAGONAL = 0
    UP = 1
    LEFT = 2

s = inp_str()
t = inp_str()
n = len(s)
m = len(t)
class node():
    def __init__(self):
        self.value = 0
        # self.angle = None
        self.ans=""
dp = [[node() for j in range(m+1)] for i in range(n+1)]
# for i in range(1,n + 1):
#     dp[i][0].angle = Angle.UP
# for j in range(1,m + 1):
#     dp[0][j].angle = Angle.LEFT
for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i + 1][j + 1].value = dp[i][j].value + 1
            dp[i + 1][j + 1].ans = dp[i][j].ans + s[i]
        elif dp[i][j + 1].value > dp[i + 1][j].value: #UP
            dp[i + 1][j + 1].ans = dp[i][j + 1].ans
            dp[i + 1][j + 1].value = dp[i][j + 1].value
        else:  # LEFT
            dp[i + 1][j + 1].ans = dp[i + 1][j].ans
            dp[i + 1][j + 1].value = dp[i + 1][j].value

            
# print(dp[n][m].value)
# for i in range(n+1):
#     for j in range(m+1):
#         print(dp[i][j].value,end="")
#     print("")
# print("")
# print("")
# for i in range(n+1):
#     for j in range(m+1):
#         print(dp[i][j].ans,end="")
#     print("")
print(dp[n][m].ans)

        

### FIXED CODE ###

import sys
input = sys.stdin.readline

s = list(input())
t = list(input())
n = len(s)-1
m = len(t)-1
value = [[0]*(m+1) for i in range(n+1)]


for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            value[i + 1][j + 1] = value[i][j] + 1
        elif value[i][j + 1] > value[i + 1][j]: #UP
            value[i + 1][j + 1] = value[i][j + 1]
        else:  # LEFT
            value[i + 1][j + 1] = value[i + 1][j]
i = n-1
j = m-1
ans=""
while i >= 0 and j >= 0:
    if s[i] == t[j]:
        ans = s[i] + ans
        i -= 1
        j -= 1
    elif value[i][j + 1] > value[i + 1][j]:
        i -= 1
    else:
        j -= 1
print(ans)
### BUGGY CODE ###

if __name__ == '__main__':
    n = int(input())
    list =[]
    for i in range(n):
        list.append(int(input()))

    list2=[]
    count = 0
    now =1
    for i in range(n):
        if now in list2:
            print(-1)
            break
        else:
            if list[now-1] ==2:
                count+=1
                print(count)
                break
            else:
                list2.append(now)
                count+=1
                now = list[now-1]

### FIXED CODE ###

if __name__ == '__main__':
    n = int(input())
    dict={}
    for i in range(n):
        dict[i] = int(input())

    dict2={}
    count = 0
    now =1
    for i in range(n):
        if now in dict2:
            print(-1)
            break
        else:
            if dict[now-1] ==2:
                count+=1
                print(count)
                break
            else:
                dict2[now]=0
                count+=1
                now = dict[now-1]
### BUGGY CODE ###

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()))
sum = 0
ans = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
Kto = K*2
while Kto:
    for i in range(X):
        for j in range(Y):
            for k in range(Z):
                sum = A[i]+B[j]+C[k]
                ans.append(sum)
                Kto -= 1
    if i == X-1 and k == Z-1:
        break
ans.sort(reverse=True)

for l in range(K):
    print(ans[l])

### FIXED CODE ###

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

ans = []

for i in range(X):
    for j in range(Y):
        if (i+1)*(j+1) > K:
            break
        for t in range(Z):
            if (i+1)*(j+1)*(t+1) > K:
                break
            ans.append(A[i]+B[j]+C[t])
ans.sort(reverse=True)

for l in range(K):
    print(ans[l])
### BUGGY CODE ###

from collections import deque
from itertools import product
h, w = map(int, input().split())
si, sj = map(lambda x: int(x)-1, input().split())
gi, gj = map(lambda x: int(x)-1, input().split())
fld = ''.join([input()for _ in range(h)])
INF = 10**18


def to_v(i, j):
    return i*w+j


n = h*w
start = to_v(si, sj)
goal = to_v(gi, gj)


def generate_v2(v):
    i, j = divmod(v, w)
    it = [-2, -1, 0, 1, 2]
    for di, dj in product(it, repeat=2):
        x, y = i+di, j+dj
        if x < 0 or h <= x or y < 0 or w <= y:
            continue
        if (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1), (0, 0)]:
            d = 0
        else:
            d = 1
        yield d, x*w+y


def bfs(init_v):
    next_v = deque([init_v])
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    visited = [0]*n
    while next_v:
        v = next_v.popleft()
        if visited[v]:
            continue
        visited[v] = 1
        for d, v2 in generate_v2(v):
            if fld[v2] == '#':
                continue
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            if d:
                next_v.append(v2)
            else:
                next_v.appendleft(v2)
    return dist


ans = bfs(start)[goal]
print(-1 if ans == INF else ans)


### FIXED CODE ###

import heapq
from itertools import product
h, w = map(int, input().split())
si, sj = map(lambda x: int(x)-1, input().split())
gi, gj = map(lambda x: int(x)-1, input().split())
fld = ''.join([input()for _ in range(h)])
INF = 10**18


def to_v(i, j):
    return i*w+j


n = h*w
start = to_v(si, sj)
goal = to_v(gi, gj)


def generate_v2(v):
    i, j = divmod(v, w)
    it = [-2, -1, 0, 1, 2]
    for di, dj in product(it, repeat=2):
        x, y = i+di, j+dj
        if x < 0 or h <= x or y < 0 or w <= y:
            continue
        if (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1), (0, 0)]:
            d = 0
        else:
            d = 1
        yield d, x*w+y


def dijkstra(init_v):
    next_v = [(0, init_v)]
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in generate_v2(v):
            if fld[v2] == '#':
                continue
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


ans = dijkstra(start)[goal]
print(-1 if ans == INF else ans)
### BUGGY CODE ###

N = int(input())
list_S = [input() for i in range(N)]

from collections import Counter
dict_C = Counter(list_S)

keys = [k for k,v in dict_C.items() if v == max(dict_C.values())]
keys.sort()

for ans in keys :
    print(ans)


### FIXED CODE ###

N = int(input())
list_S = [input() for i in range(N)]

from collections import Counter
dict_C = Counter(list_S)
max = max(dict_C.values())

keys = [k for k,v in dict_C.items() if v == max]
keys.sort()

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

import numpy as np
N,T = map(int,input().split())
A=np.array(input().split(),dtype=np.int32)
s=[]
count=0
for i in range(1,N):
  s += [A[i]-min(A[0:i])]
for j in range(len(s)):
  if s[j]==max(s):
    count +=1
print(count)

### FIXED CODE ###

import numpy as np
N,T = map(int,input().split())
A=np.array(input().split(),dtype=np.int32)
s=A-np.minimum.accumulate(A)
print((s==max(s)).sum())
### BUGGY CODE ###

def main():
    n, m = map(int, input().split())
    st = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in st]
    toP = [0]*n
    toE = [0]*n
    fromE = [0]*n
    toP[0] = 1
    for i in range(n-1):
        p = toP[i]
        if p > 0:
            toE[i] /= toP[i]
        e = toE[i]
        l = len(g[i])
        for j in g[i]:
            toP[j] += p/l
            toE[j] += (e+1)*p/l
    for i in range(n-2, -1, -1):
        l = len(g[i])
        for j in g[i]:
            fromE[i] += (fromE[j]+1)/l
    allE = fromE[0]
    ans = fromE[0]
    for s, t in st:
        if g[s-1]:
            temp = allE
            l = len(g[s-1])
            if l < 2:
                continue
            p = toP[s-1]
            temp = allE
            for j in g[s-1]:
                temp -= p*(toE[s-1]+1+fromE[j])/l
                if j != t-1:
                    temp += p*(toE[s-1]+1+fromE[j])/(l-1)
            ans = min(temp, ans)
    print(ans)


main()

### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    st = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in st]
    toP = [0]*n
    toE = [0]*n
    fromE = [0]*n
    toP[0] = 1
    for i in range(n-1):
        p = toP[i]
        if p > 0:
            toE[i] /= toP[i]
        e = toE[i]
        l = len(g[i])
        for j in g[i]:
            toP[j] += p/l
            toE[j] += (e+1)*p/l
    for i in range(n-2, -1, -1):
        l = len(g[i])
        for j in g[i]:
            fromE[i] += (fromE[j]+1)/l
    allE = fromE[0]
    ans = fromE[0]
    for s, t in st:
        if g[s-1]:
            temp = allE
            l = len(g[s-1])
            if l < 2:
                continue
            p = toP[s-1]
            temp = allE
            for j in g[s-1]:
                temp -= p*(toE[s-1]+1+fromE[j])/l
                if j != t-1:
                    temp += p*(toE[s-1]+1+fromE[j])/(l-1)
            ans = min(temp, ans)
    print(ans)


main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n,m= map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
yoko=0
tate=0
for i in range (0,n-1):
  for j in range (i+1,n):
    yoko+=x[j]-x[i]
for i in range (0,m-1):
  for j in range (i+1,m):
    tate+=y[j]-y[i]

print(yoko*tate%(10**9+7))

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
n,m= map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
yoko=0
tate=0
for i in range (0,len(x)):
  yoko+=(n-2*i-1)*x[i]
for i in range (0,len(y)):
  tate+=(m-2*i-1)*y[i]

print(yoko*tate%(10**9+7))
### BUGGY CODE ###

n = int(input())
plist = list(map(int,input().split()))

islow = True
counter = 0
min = 0

for i in range(len(plist)):
    islow = True
    if i == 0:
        counter += 1
        min = plist[i]
    elif min > plist[i]:
        for j in range(plist.index(plist[i])):
            if plist[i] <= plist[j]:
                pass
            else:
                islow = False
                break
        if islow:
            counter += 1
            min = plist[i]
print(counter)      

### FIXED CODE ###

n = int(input())
plist = list(map(int,input().split()))

islow = True
counter = 0
min = 0

for i in range(len(plist)):
    islow = True
    if i == 0:
        counter += 1
        min = plist[i]
        current_min = i
    elif min > plist[i]:
        counter += 1
        min = plist[i]
        current_min = i
        
print(counter)
### BUGGY CODE ###

s = input()

def make_num(x,y):
    return int(s[x:y])
l = [make_num(i,j) for i in range(len(s)-3) for j in range(i+4, len(s)+1) if make_num(i,j)%2019 ==0]
print(len(l))


### FIXED CODE ###

S = input()
count = 0
l = [0] * 2019 #mod2019 は0~2018まで
l[0] = 1
mod = 2019
tmp = 0

for i in range(1, len(S) + 1):
    tmp = (tmp + int(S[len(S) - i]) * pow(10, i - 1, mod)) % mod
    #print(tmp)
    l[tmp] += 1

#print(l)
for j in range(2019):
    if l[j] >= 2:
        count += l[j] * (l[j] - 1) // 2

print(count)
### BUGGY CODE ###

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

duplication = {}
ans = 0
for x in A:
    if x in duplication:
        continue
    count = A.count(x)
    if count > 1:
        duplication[x] = count
        for i in range(1,count):
            ans += i
for x in A:
    if x not in duplication:
        print(ans)
    else:
        print(ans -duplication[x]+1)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
# TLE
def test():
    duplication = {}
    ans = 0
    for x in A:
        if x in duplication:
            continue
        count = A.count(x)
        if count > 1:
            duplication[x] = count
            ans += count*(count-1)//2
    for x in A:
        if x not in duplication:
            print(ans)
        else:
            print(ans -(duplication[x]-1))
from collections import defaultdict

sum = 0
count_dic = defaultdict(int)
for x in A:
    count_dic[x] +=1
for v in count_dic.values():
    sum += v*(v-1)//2
for x in A:
    print(sum -(count_dic[x]-1))
### BUGGY CODE ###

n,K=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
c=list(map(int,input().split()))
if K == 1:
    print(max(c));exit()
ans = -10**10
def cycle(k):
    mo=k
    clen=0
    cscore=0
    flg = True
    cmax=[-10**10]
    while (mo != k or flg):
        clen+=1
        cscore+=c[mo]
        mo = p[mo]
        cmax.append(max(cmax[-1],cscore))
        if mo == k:
            flg = False
    if cscore<0:
        return cmax[min(K-1,clen-1)],cmax
    return cscore*((K-1)//clen)+cmax[(K-1)%clen+1],cmax
for i in range(n):
    a,l=cycle(i)
    if a>ans:
        ans = a
print(ans)

### FIXED CODE ###

n,K=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
c=list(map(int,input().split()))
if K == 1:
    print(max(c));exit()
ans = -10**10
def cycle(k):
    mo=k
    clen=0
    cscore=0
    flg = True
    cmax=[-10**10]
    while (mo != k or flg):
        clen+=1
        cscore+=c[mo]
        mo = p[mo]
        cmax.append(max(cmax[-1],cscore))
        if mo == k:
            flg = False
    if cscore<0:
        return cmax[min(K-1,clen-1)],cmax
    return cscore*((K-1)//clen)+cmax[(K-1)%clen+1],cmax
for i in range(n):
    a,l=cycle(i)
    if a>ans:
        ans = a
print(ans)
### BUGGY CODE ###

N=int(input())
a=4/N
h_st=max(int(N*(1/4))-1,1)
#h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if 4*h*n*n-(n*n+h*n+h*n)*N<=0 and 4*h*n*3500-(n*3500+h*3500+h*n)*N>=0:

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)


### FIXED CODE ###

N=int(input())
a=4/N
h_st=max(int(N*(1/4))-1,1)
#h_st=1
for h in range(h_st,3501):
    H=1/h
    for n in range(h,3501):
        flag=0
        if 4*h*n*n-(n*n+h*n+h*n)*N<=0 and 4*h*n*3500-(n*3500+h*3500+h*n)*N>=0:

            st,end=n,3500
            for w in [st,end]:
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
            while st!=end:
                #print(h,n,st,end)
                w=int((st+end)/2)
                if end-st==1:
                    end=w
                    st=w
                B=4*h*n*w-(n*w+h*w+h*n)*N
                if B==0:
                    flag=1
                    break
                elif B>0:
                    end=w
                else:
                    st=w

        if flag:
            break
    if flag:
        break

print(h,n,w)
### BUGGY CODE ###

S = input()
q = int(input())

reverse = False
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:#2
        if query[1] == '1':
            if reverse:
                S = S + query[2]
            else:
                S = query[2] + S
        else:
            if reverse:
                S = query[2] + S
            else:
                S = S + query[2]
print(S[::-1] if reverse else S)

### FIXED CODE ###

from collections import deque

S = deque(input())
q = int(input())

reverse = False
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:#2
        if query[1] == '1':
            if reverse:
                S.append(query[2])
            else:
                S.appendleft(query[2])
        else:
            if reverse:
                S.appendleft(query[2])
            else:
                S.append(query[2])

if reverse:
    while S:
        print(S.pop(), end='')
else:
    while S:
        print(S.popleft(), end='')
### BUGGY CODE ###

N=int(input())
c=0
INF=2000000
x=[0 for _ in range(INF)]
y=[0 for _ in range(INF)]

for i in range(N):
    for j in range(N) :
        if (i+1)*(j+1)==N:
            x[c]=i
            y[c]=j
            c+=1

d=INF
for i in range(c):
    if d>(x[i]+y[i]):
        d=x[i]+y[i]

print(d)

### FIXED CODE ###

N=int(input())
c=0
d=10000000000000
rN=int(N**0.5)

for i in range(rN):
    if (N%(i+1)==0) :
        x=i+1
        y=int(N/(i+1))
        if d>(x+y):
            d=x+y

print(d-2)
### BUGGY CODE ###

def main():
  k, q = map(int, input().split())
  d = list(map(int, input().split()))
  for i in range(q):
    n, x, m = map(int, input().split())
    x %= m
    d_mod = []
    for i in d:
      i_mod = i % m
      if i_mod == 0:
        d_mod.append(m)
      else:
        d_mod.append(i_mod)
    d_mod_sum = sum(d_mod)
    rep = (n-1) // k
    rem = (n-1) % k
    rem_sum = sum(d_mod[:rem])
    ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
    print(ans)
if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  import numpy as np
  k, q = map(int, input().split())
  d = np.array(list(map(int, input().split())))
  for i in range(q):
    n, x, m = map(int, input().split())
    x %= m
    d_mod = d % m
    zero_d = k - np.count_nonzero(d_mod)
    d_mod_sum = np.sum(d_mod) + m * zero_d
    rep = (n-1) // k
    rem = (n-1) % k
    zero_rem = len(d_mod[:rem]) - np.count_nonzero(d_mod[:rem])
    rem_sum = np.sum(d_mod[:rem]) + m * zero_rem
    ans = n - 1 - (x + d_mod_sum * rep + rem_sum) // m
    print(ans)
if __name__ == '__main__':
  main()
### BUGGY CODE ###

n = int(input())
print(sum(x for x in range(n)))


### FIXED CODE ###

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

s = input()
q = int(input())
flag = True
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        flag = not flag
    else:
        if (query[1] == "1" and flag) or (query[1] == "2" and not flag):
            s = query[2] + s
        else:
            s = s + query[2]
sf = 1 if flag else -1
print(s[::sf])


### FIXED CODE ###

from collections import deque

s = deque(input())
q = int(input())
flag = True
for _ in range(q):
    query = input().split()
    if query[0] == "1":
        flag = not flag
    else:
        if (query[1] == "1" and flag) or (query[1] == "2" and not flag):
            s.appendleft(query[2])
        else:
            s.append(query[2])
if not flag:
    s.reverse()
print(''.join(s))
### BUGGY CODE ###

s = input()
q = int(input())
count = 0
for _ in range(q):
  query = input()
  if query[0] == "1":
    count += 1
  if count%2 == 0:
    if query[0] == "2":
      if query[2] == "1":
        s = query[4] + s
      if query[2] == "2":
        s = s + query[4]
        
  else:
    if query[0] == "2":
      if query[2] == "1":
        s = s + query[4]
      if query[2] == "2":
        s = query[4] + s

if count%2 != 0:
  s = s[::-1]
print(s)

### FIXED CODE ###

s = input()
q = int(input())
c = 0
l = []
r = []

for i in range(q):
  query = input()
  if query[0] == "1":
    c += 1
    a = l
    l = r
    r = a
  if query[0] == "2":
    if query[2] == "1":
      l.append(query[4])
    if query[2] == "2":
      r.append(query[4])
      
l = "".join(l)
l = l[::-1]
r = "".join(r)
      
if c%2 == 1:
  s = s[::-1]
  
print(l + s + r)
### BUGGY CODE ###

N = int(input())
X = list(map(int, input().split( )))
for l in range(N):
    Y = X[ : ]
    del Y[l]
    Y.sort( )
    l = N//2-1
    print(Y[l])

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split( )))
X1 = X[ : ]
X1.sort()
for l in range(N):
    if X[l] <= X1[N//2-1]:
        print(X1[N//2])
    else:
        print(X1[N//2-1])
### BUGGY CODE ###

S=input()
Q=int(input())
import sys
from collections import deque
d=deque()
for _ in S:
  d.append(_)
 
for _ in range(Q):
  s = list(sys.stdin.readline())
  if s[0]=="1":
    d.reverse()
  else:
    if s[2]=="1":
      d.appendleft(s[4])
    else:
      d.append(s[4])
      
print("".join(d))

### FIXED CODE ###

S=input()
Q=int(input())
import sys
from collections import deque
d=deque()
for _ in S:
  d.append(_)
flag=False

for _ in range(Q):
  s = list(sys.stdin.readline())
  if s[0]=="1":
    if flag:
      flag=False
    else:
      flag=True
  else:
    if s[2]=="1":
      if flag:
        d.append(s[4])
      else:
        d.appendleft(s[4])
    else:
      if flag:
        d.appendleft(s[4])
      else:
        d.append(s[4])
      
if flag:
  d.reverse()
  
print("".join(d))
### BUGGY CODE ###

import numpy as np

n, x, y = map(int, input().split())

ans = []
for i in range(1, n+1):
  for j in range(1, n+1):
    if i <= j:
      ji = i - j
      xi = i - x
      jy = y - j
      yi = i - y
      jx = x - j
      l = [np.abs(ji),  np.abs(xi) + 1 + np.abs(jy)]
      m = min(l)
      ans.append(m)
      
    
for k in range(n-1):
  print(ans.count(k+1))


### FIXED CODE ###

n, x, y = map(int, input().split())

ans = [0]*n
for i in range(1, n+1):
  for j in range(i, n+1):
    m = min(j-i,  abs(x-i) + 1 + abs(j-y))
    ans[m] += 1
      
print(*ans[1:], sep = '\n')