Harryxun/stf_run huggingface dataset:
n,k=list(map(int,input().split()))
a=[0]+ list(map(int,input().split()))

visited=[1]

for i in range(n):
  next=a[visited[-1]]
  visited.append(next)
  
loop_end=n
loop_start=n-1
while visited[loop_start]!=visited[loop_end]:
  loop_start-=1
period=loop_end-loop_start
#print(visited) 
#print("p:",period)
#print("k%period:",k%period)

if k<n+1:
  print(visited[k])
  exit()
else:
  print(visited[n-(k-n)%period+1])

### FIXED CODE ###

n,k=list(map(int,input().split()))
a=[0]+ list(map(int,input().split()))

visited=[1]

for i in range(n):
  next=a[visited[-1]]
  visited.append(next)
  
loop_end=n
loop_start=n-1
while visited[loop_start]!=visited[loop_end]:
  loop_start-=1
period=loop_end-loop_start
#print(visited) 
#print("p:",period)
#print("(k-n)%period:",(k-n)%period)

if k<n+1:
  print(visited[k])
  exit()
else:
  print(visited[n-period+(k-n)%period])
# coding: utf-8
n = int(input())

high = list(map(int, input().split()))
max_high = []
count =1

for i in range(1,n):
    x = high[:i]
    if(max(x) <= high[i]):
        count++
        
print(count)

### FIXED CODE ###

# coding: utf-8
n = int(input())

high = list(map(int, input().split()))
max_high = []
count =1

for i in range(1,n):
    x = high[:i]
    if(max(x) <= high[i]):
        count = count +1
        
print(count)
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
ans = 1
flag = 0
#第1項が割り切れる場合答えは0。割り切れるとしたら次の項で可能。
if A[0] % A[1] == 0:
  print(0)
  exit()
#第二項以降を考える。
for i in range(1,N):
  for j in range(i-1):
    if A[i] % A[j] == 0:
      flag += 1
  if flag == 0:
    ans += 1
  else:
    flag = 0
    
print(ans)

### FIXED CODE ###

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

d = {}
for a in A:
  d.setdefault(a,0)
  d[a] += 1
  
A = sorted(set(A))
t = [True] * (10 ** 6 + 1)
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]))
has_seven = False
N = str(N)
for i in range(len(N)):
  	if N[i] == '7':
    	has_seven = True
    	break

if has_seven:
	print("Yes")
else:
    print("No")




### FIXED CODE ###


has_seven = False
N = str(input())
for i in range(len(N)):
  if N[i] == '7':
      has_seven = True
      break

if has_seven:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(W) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

visit=defaultdict(lambda: 0) #未訪問:0 訪問済み:1
d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0
visit[(CH,CW)]=1

while q:
    kyori, fro_h, fro_w=q.popleft()
    visit[(fro_h, fro_w)]=1
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
            if kyori < d[(to_h, to_w)]:
                visit[(to_h, to_w)]=1
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori,to_h, to_w))

    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]=="." and visit[(to_h, to_w)]==0:
            if kyori+1 < d[(to_h, to_w)]:
                visit[(to_h, to_w)]=1
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1,to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

if d[(DH,DW)]==float("inf"):
    print -1
else:
    print d[(DH,DW)]
# 1.Nが三の倍数でない場合、全てが0でなければならない.(a_i=Σa_k∧a_(i-1)+a_(i+1)=a_iとなるのはa_i=0のみ)
# 2.Nが3の倍数の場合、a,b,a+bを満たす三種類以下の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
string = "No"
input_dict = {}
for i in map(int, input().split()):
    if(i in input_dict):
        input_dict[i] += 1
    else:
        input_dict[i] = 1
if((N % 3) == 0):
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[1] == input_list[2] and input_dict[input_list[0] == N//3 and input_dict[input_list[1]]] == N//3):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    if(0 in input_dict and input_dict[0] == N):
        string = "Yes"
print(string)


### FIXED CODE ###

# 1.Nが三の倍数でない場合、全てが0でなければならない.(a_i=Σa_k∧a_(i-1)+a_(i+1)=a_iとなるのはa_i=0のみ)
# 2.Nが3の倍数の場合、a,b,a+bを満たす三種類以下の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
string = "No"
input_dict = {}
for i in map(int, input().split()):
    if(i in input_dict):
        input_dict[i] += 1
    else:
        input_dict[i] = 1
if((N % 3) == 0):
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[1] == input_list[2] and input_dict[input_list[0]] == N//3 and input_dict[input_list[1]] == N//3):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    if(0 in input_dict and input_dict[0] == N):
        string = "Yes"
print(string)
n, x, d = map(int, input().split())

ranges = {}

for k in range(n+1):
    mod = k * x % d
    l = k * x // d + k * (k-1)//2
    r = k * x // d + k * (2*n-k-1)//2
    if mod not in ranges:
        ranges[mod] = []
    ranges[mod].append((l,-1)) 
    ranges[mod].append((r+1, 1))

ans = 0
    
for mod in ranges:
    lrs = ranges[mod]
    lrs.sort()
    cnt = 0
    last = -1
    for x,y in lrs:
        if cnt == 0:last = x
        cnt += y
        if cnt == 0:
            ans += x - last

print(ans)
    

### FIXED CODE ###

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

if d == 0:
    if x == 0:print(1)
    else:print(n+1)
    exit(0)

ranges = {}

for k in range(n+1):
    mod = k * x % d
    l = k * x // d + k * (k-1)//2
    r = k * x // d + k * (2*n-k-1)//2
    if mod not in ranges:
        ranges[mod] = []
    ranges[mod].append((l,-1)) 
    ranges[mod].append((r+1, 1))

ans = 0
    
for mod in ranges:
    lrs = ranges[mod]
    lrs.sort()
    cnt = 0
    last = -1
    for x,y in lrs:
        if cnt == 0:last = x
        cnt += y
        if cnt == 0:
            ans += x - last

print(ans)
from collections import Counter

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
            
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            

N, M = map(int, input().split())
UF = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    big = max(a, b)
    small = min(a, b)
    
    if UF.par[big] == big:
        UF.par[big] = small
    else:
        UF.union(big, small)

c = Counter(UF.par)
print(max(c.values()))

### FIXED CODE ###

from collections import Counter

class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
                
n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

for i in range(n):
    uf.find(i)

c = Counter(uf.par)
print(max(c.values()))
yukichi = -1
higuchi = -1
noguchi = -1


def check(n,y,a,b,c):

    if y/1000 == n:
        global yukichi,higuchi,noguchi
        yukichi = a
        higuchi = b
        noguchi = n

    else:
        if y>=0:
            check(n-1,y-10000,a+1,b,c)
            check(n-1,y-5000,a,b+1,c)


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

check(n,y,0,0,0)

print("{} {} {}".format(yukichi,higuchi,noguchi))

### FIXED CODE ###

n,y = map(int,input().split())
yukichi = -1
higuchi = -1
noguchi = -1
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            yukichi = i
            higuchi = j
            noguchi = n-i-j

print("{} {} {}".format(yukichi,higuchi,noguchi))
n =int(input())
a =list(map(int, input().split()))

a_min = min(a)
a_max = max(a)

n = a_max - a_min

for i in range(n):
    z = i + a_min
    hp = 0
    for x in a:
        hp += (x - z) ** 2
    if i == 0:
        ans = hp
    if ans > hp:
        ans = hp

print(ans)

### FIXED CODE ###

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

a_min = min(a)


for i in range(100):
    z = i + a_min
    hp = 0
    for x in a:
        hp += (x - z) ** 2
    if i == 0:
        ans = hp
    if ans > hp:
        ans = hp

print(ans)
x=int(input())
print(x//3600,x//60%60,x%60,


### FIXED CODE ###

x=int(input())


print(x//3600,x//60%60,x%60,sep=':')
n = input()

if n(0) == n(-1):
    print("Yes")
else:
    print("No")


### FIXED CODE ###


n = input()

if n[0] == n[-1]:
    print("Yes")
else:
    print("No")
n,k=map(int,input().split())
step=list(map(int,input().split()))
dp=[0]*n
for i in range(1,k):
  min=10**7
  for j in range(1,i+1):
    if dp[i-j]+abs(step[i]-step[i-j])<min:
      min=dp[i-j]+abs(step[i]-step[i-j])
  dp[i]=min
for i in range(k,n):
  min=10**7
  for j in range(1,k+1):
    if dp[i-j]+abs(step[i]-step[i-j])<min:
      min=dp[i-j]+abs(step[i]-step[i-j])
  dp[i]=min
print(dp[n-1])

### FIXED CODE ###

def solve():
  n,k=[int(i) for i in input().split()]
  step=[int(i) for i in input().split()]
  dp=[0]*n
  for i in range(1,n):
    dp[i]=min([dp[j] + abs(step[i]-step[j]) for j in range(max(i-k,0),i)])
  return dp[n-1]
print(solve())
N = int(input())
listA = list(map(int, input()))
cnt = 0

while(True):
    for A in listA:
        if A % 2 != 0:
            break
        else:
            A = A / 2
    
    cnt += 1
print(cnt)

### FIXED CODE ###

s = input()

print(s.count("1"))
N, K = map(int,input().split()) # 複数の数字を変数に格納

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
  
red = N - K
blue = K
division = 10 ** 9 + 7

for i in range(K):
    if i > red:
        print("{} 0".format(i+1))
    else:
        tmp_blue = cmb(blue-1,i)
        tmp_red = 1
        for j in range(i+1):
            tmp_red = tmp_red * (red+1-j) / (j+1) 
        result = int(tmp_blue * tmp_red % division)
        print("{} {}".format(i+1,result))


### FIXED CODE ###

N, K = map(int,input().split()) # 複数の数字を変数に格納

red = N - K
blue = K
division = 10 ** 9 + 7

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under % division
  
for i in range(K):
    if i > red:
        print("0")
    else:
        tmp_blue = cmb(blue-1,i) % division
        tmp_red = cmb(red+1,red-i)
        result = int(tmp_blue * tmp_red % division)
        print("{}".format(result))
h,w=map(int,input())
print("#"*(w+2))
for i in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))

### FIXED CODE ###

h,w=map(int,input().split())
print("#"*(w+2))
for i in range(h):
  print("#"+input().strip()+"#")
print("#"*(w+2))
coding: utf-8
 
N  = int(input())
sum = 0
 
for i in range(N):
    if ( i % 3 != 0):
        if (i % 5 != 0):
           sum += i
 
print(sum)

### FIXED CODE ###

#coding: utf-8
 
N  = int(input())
sum = 0
 
for i in range(N+1):
    if ( i % 3 != 0):
        if (i % 5 != 0):
           sum += i
 
print(sum)
if A*B%2==0:
    print('No')
else :
    print('Yes')

### FIXED CODE ###

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


if (A*B)%2==0:
    print('No')
else :
    print('Yes')
import math

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)

if d % 10 != 0:
  x.append(d % 10)

if e % 10 != 0:
  x.append(e % 10)

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 + min(x))



### FIXED CODE ###

import math
import numpy as np

a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())
x = []
s = 0

if a % 10 != 0:
  x.append(a % 10)

if b % 10 != 0:
  x.append(b % 10)

if c % 10 != 0:
  x.append(c % 10)


if d % 10 != 0:
  x.append(d % 10)


if e % 10 != 0:
  x.append(e % 10)

s = 0

if len(x) != 0:
  if np.amin(x) !=0:
    s = 10
  y = np.amin(x)
else:
  s = 0
  y = 0

print(math.ceil(a/10)*10 +  math.ceil(b/10)*10 +  math.ceil(c/10)*10 +  math.ceil(d/10)*10 +  math.ceil(e/10)*10 +  y -s )
def min_cost(stones, N):
    def jump(stones, index, N):
        if index == N:
            return 0

        if memo[index] != -1:
            return memo[index]

        left = abs(stones[index] - stones[index + 1]) + jump(stones, index + 1, N)

        right = 2 ** 31
        if index + 2 <= N:
            right = abs(stones[index] - stones[index + 2]) + jump(stones, index + 2, N)

        memo[index] = min(left, right)

        return memo[index]

    memo = [-1] * N
    return jump(stones, 0, N - 1)


if __name__ == '__main__':
    N = int(input())
    #stones = list(map(int, input().strip().split()))
    stones = [int(a) for a in input().strip().split()]
    print(min_cost(stones, N))
    
    '''
    stones = [30, 10, 60, 10, 60, 50]
    N = 6
    print(min_cost(stones, N))
    

    stones = [10, 30, 40, 20]
    N = 4
    print(min_cost(stones, N))
    '''
    



### FIXED CODE ###



def min_cost(stones, N):
    space = [0] * N

    for i in range(1, N):
        one = abs(stones[i] - stones[i - 1]) + space[i - 1]
        
        two = 2 ** 31

        if i - 2 >= 0:
            two = abs(stones[i] - stones[i - 2]) + space[i - 2]

        space[i] = min(one, two)

    return space[i]


if __name__ == '__main__':
    N = int(input())
    #stones = list(map(int, input().strip().split()))
    stones = [int(a) for a in input().strip().split()]
    print(min_cost(stones, N))
    
    '''
    stones = [30, 10, 60, 10, 60, 50]
    N = 6
    print(min_cost(stones, N))
    

    stones = [10, 30, 40, 20]
    N = 4
    print(min_cost(stones, N))
    '''
a = int(input())
b = b**3
print(b)

### FIXED CODE ###

x = int(input())
x = x**3
print(x)
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  for i in range(b,d+1):
    if s[i-1:i+2]=="...":
      e = 1 
  if e = 1:
    print("Yes")
  elif:
    print("No")

### FIXED CODE ###

n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c-1].count("##")==0 and s[b:d-1].count("##")==0:
    for i in range(b-1,d):
      if s[i-1:i+2]=="..." :
        e = 1 
    if e == 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
def main():
    H, W = map(int, input().split())
    S = ['.'*W]+['.'+input()+'.' for _ in range(H)]+['.'*W]

    for h in range(1, H+1):
        for w in range(1, W+1):
            if S[h][w] == '#':
                if S[h-1][w] == '.' and S[h+1][w] == '.' and S[h][w+1] == '.' and S[h][w-1] == '.':
                    return False
    return True


print('Yes' if main() else 'No')


### FIXED CODE ###

def main():
    H, W = map(int, input().split())
    S = ['.'*(W+2)]+['.'+input()+'.' for _ in range(H)]+['.'*(W+2)]

    for h in range(1, H+1):
        for w in range(1, W+1):
            if S[h][w] == '#':
                if S[h-1][w] == '.' and S[h+1][w] == '.' and S[h][w+1] == '.' and S[h][w-1] == '.':
                    return False
    return True


print('Yes' if main() else 'No')
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5+1:
        del a[i]
        ans += 1
        
counts = [0] * (10 ** 5 + 1)

for i in range(len(a)):
    counts[a[i]] += 1
    
for i in range(1,len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
ans = 0
idx = []
for i,x in enumerate(a):
    if x > 10**5:
        ans += 1
        idx += [i]
for i in reversed(idx):
    del a[i]

import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)
w

### FIXED CODE ###

a,b,c = map(int,input().split())
print(c,a,b)
a, b, c = map(int, input().split())
if abs(x - a) > abs(x - b):
    print('B')
else:
    print('A')

### FIXED CODE ###

x,a,b = map(int, input().split())
if abs(x - a) > abs(x - b):
    print('B')
else:
    print('A')
[n,k] = map(int, input().split())
SET = set()
for i in range(k):
	d = int(input())
    tmp = set(map(int, input().split()))
    SET = (SET|tmp)

print(n-int(len(SET)))

### FIXED CODE ###

[n,k] = map(int, input().split())
SET = set()
for i in range(k):
  d = int(input())
  tmp = set(map(int, input().split()))
  SET = (SET|tmp)
print(n-int(len(SET)))
#encoding utf-8


n = input()

if n > 999:
    print("ABD")

else:
    print("ABC")

### FIXED CODE ###

#encoding utf-8


n = int(input())

if n > 999:
    print("ABD")

else:
    print("ABC")
import sys

sys.setrecursionlimit(100000000)


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    return grundy(a - d - 1, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')


### FIXED CODE ###

import sys

sys.setrecursionlimit(10000000)
from math import ceil


def grundy(a, k):
    if a < k:
        return 0
    d, m = divmod(a, k)
    if m == 0:
        return d
    d1 = d + 1
    if d > k:
        return grundy(a - d1, k)
    e = ceil(m / d1) * d1
    return grundy(a - e, k)


n = int(input())
nim = 0
for _ in range(n):
    a, k = map(int, input().split())
    nim ^= grundy(a, k)
print('Takahashi' if nim > 0 else 'Aoki')
vn,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print("".join(s))

### FIXED CODE ###

n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
print("".join(s))
list = raw_input().split()
if list[0] <= list[1]:
  print list[0]
else:
  print list[0] - 1


### FIXED CODE ###

list = raw_input().split()
if list[0] <= list[1]:
  print list[0]
else:
  print int(list[0]) - 1
import numpy as np

h, w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]

a = np.array(a)
b = np.array(b)
ab = abs(a - b)
ab0 = ab[0][0]
size = 80*(h+w)
dp = np.zeros((h, w, 1 + size), dtype='bool')
dp[0][0][size//2 + ab0] = True # size//2が0に相当
dp[0][0][size//2 - ab0] = True
for ch in range(h):
    for cw in range(w):
        for ck in range(1 + size): 
            if dp[ch][cw][ck]:
                if ch < h-1:
                    dp[ch+1][cw][ck + ab[ch+1][cw]] = True
                    dp[ch+1][cw][ck - ab[ch+1][cw]] = True
                if cw < w-1:
                    dp[ch][cw+1][ck + ab[ch][cw+1]] = True
                    dp[ch][cw+1][ck - ab[ch][cw+1]] = True

for i in range(1 + size//2):
    for j in [1, -1]:
        if dp[h-1][w-1][size//2 + i*j]:
            print(i)
            exit()

### FIXED CODE ###

h, w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]

ab = [[0]*w for i in range(h)]
for ch in range(h):
    for cw in range(w):
        ab[ch][cw] = abs(a[ch][cw] - b[ch][cw])

ab0 = ab[0][0]
size = 80*(h+w)
dp = [[0]*w for hh in range(h)]
dp[0][0] |= 2**(size + ab0)
dp[0][0] |= 2**(size - ab0)
for ch in range(h):
    for cw in range(w):
        if ch < h-1:
            dp[ch+1][cw] |= dp[ch][cw] << ab[ch+1][cw]
            dp[ch+1][cw] |= dp[ch][cw] >> ab[ch+1][cw]
        if cw < w-1:
            dp[ch][cw+1] |= dp[ch][cw] << ab[ch][cw+1]
            dp[ch][cw+1] |= dp[ch][cw] >> ab[ch][cw+1]

a = dp[h-1][w-1]>>size
m = a&(-a)
print(m.bit_length()-1)
n=int(input())
m==111
for i in range(1,10):
    if 111*i>=n:
        m=min(m,111*i)
print(m)
    

### FIXED CODE ###

n=int(input())
m=999
for i in range(1,10):
    if 111*i>=n:
        m=min(m,111*i)
print(m)
A,B = map(int, input().split())
if B==1:
  print(0)
else if B<A:
  print(1)
else:
  print(B//(A-1))

### FIXED CODE ###

import math
A,B = map(int, input().split())
print(math.ceil((B-1)/(A-1)))
s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while True:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)

### FIXED CODE ###

s=list(input())
k=["k","e","y","e","n","c","e"]
ans="NO"
c=0
if len(s)>=7:
    while c<7:
        if s[c]!=k[c]:
            break
        c+=1
    if c==7:
        ans="YES"
    for i in range(7-c):
        if s[-i-1]!=k[-i-1]:
            break
    else:
        ans="YES"
print(ans)
N, M = map(int, input().split())
Edge = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    Edge[a - 1] += 1
    Edge[b - 1] += 1
if any([i%2 == 1 for i in Edge]):
    print('No')
elif len([i for i in Edge if i > 4]) > 0:
    print('Yes')
elif len([i for i in Edge if i > 2]) > 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from sys import exit
N = int(input())
B = list(map(int, input().split()))
ctr = 0
ans = []
for _ in range(N):
    ctr = 0
    for i, b in enumerate(B, 1):
        if i == b:
            ctr = i
    ans.append(ctr)
    if ctr == 0:
        print(-1)
        exit()
    B = B[:ctr-1] + B[ctr:]
print('\n'.join([str(s) for s in ans][::-1]))