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

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i in range(n-1):
    a = x[i]*x[i] + y[i]*y[i]
    if a <= d*d:
        count += 1
print(count)


### FIXED CODE ###

c = list(map(int, input().split()))
n, d = c[0], c[1]

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for l in range(n):
    a = x[l]*x[l] + y[l]*y[l]
    if a <= d*d:
        count += 1
print(count)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]
 
for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])
 
check = [False for _ in range(N)]

def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:         
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]
 
for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])
 
check = [False for _ in range(N)]
 
def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:         
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1

print(ans)
while True:
  x, y = map(int, raw_input().split())
   if x>y:
    print y, x 
    continue
   elif x<y:
    print x, y
    continue
   else x == 0 and y == 0:
    break

### FIXED CODE ###

while True:
  x, y = map(int, raw_input().split())
  if x == 0 and y == 0:
    break
  elif x > y:
    print y, x 
  elif x < y or x == y:
    print x, y
b = [int(e) for e in input().split()]
count=0

for i in range(b[0]+1):
    for j in range(b[1]+1):
        for k in range(b[2]+1):
            x = 500*i+100*j+50*k
            if(x == b[3]):
                count += 1

print(count)

### FIXED CODE ###

#b = [int(e) for e in input().split()]
a=input()
a=int(a)
b=input()
b=int(b)
c=input()
c=int(c)
d=input()
d=int(d)


count=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            x = 500*i+100*j+50*k
            if(x == d):
                count += 1

print(count)
n = int(input())
total = 0
for i in range(len(n)):
  total+=n[i]
if(total == 0):
  print("No")
if(n % total == 0):
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

n = input()
num = int(n)
total = 0
for i in n:
    total += int(i)
    
if num % total == 0:
    print("Yes")
else:
    print("No")
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range (a+1):
    for j in range (b+1):
        for k in range (c+1):
            if 500*i+100*j+50*k == x:
                ans += 1
print(ans)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())

c = x-a
d = c/b
e = x-a-int(d)*b
print(e)
import math
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

k = b-a+1

amri_c = a % c
if amri_c == 0:
    amri_c = c
    k_c = (k - (amri_c - 1)) // c
else:
    k_c = (k - (amri_c - 1)) // c + 1

amri_d = a % d
if amri_d == 0:
    amri_d = d
    k_d = (k - (amri_d - 1)) // d
else:
    k_d = (k - (amri_d - 1)) // d + 1

amri_cd = a % lcm(c, d)
if amri_cd == 0:
    amri_cd = lcm(c, d)
    k_cd = (k - (amri_cd - 1)) // lcm(c, d)
else:
    k_cd = (k - (amri_cd - 1)) // lcm(c, d) + 1

ans = k-k_c-k_d+k_cd

print(ans)

### FIXED CODE ###

import fractions
a, b, c, d = map(int, input().split())
ans = 0

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def k(x):
    return x - (x//c + x//d - x//lcm(c, d))

print(k(b)-k(a-1))
n = int(input())

c = 0
for i in range(n+1)
    c +=i
print(c)

### FIXED CODE ###

n = int(input())

c = 0
for i in range(n+1):
    c +=i
print(c)
N = int(input())
A = [int(i) for i in input().split()]

def calc_sadness(points, b):
    return sum([abs(y - (b + x)) for x, y in points])

# y = x + b
# b = y - x
b_list = [y - x for x, y in points]
b_list.sort(reverse=True)


max_b = b_list[0]
min_b = b_list[-1]


def search(max_b, min_b):

    eval_max = eval_sadness(points, max_b)
    eval_min = eval_sadness(points, min_b)
    
    if max_b == min_b + 1:     # neighbors
        return min(eval_max, eval_min)
    
    mid_b = (max_b + min_b) // 2
    eval_mid = eval_sadness(points, mid_b)

    minimum = min(eval_max, eval_mid, eval_min)
    #print(eval_mid)

    if minimum == eval_max:
        return eval_max
    elif minimum == eval_min:
        return eval_min
    else:
        return min(search(max_b, mid_b), search(mid_b, min_b))

if max_b == min_b:
    print(calc_sadness(points, min_b))
else:
    print(search(max_b, min_b))

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
def calc_sadness(points, b):
    return sum([abs(y - (b + x)) for x, y in points])

points = [(i+1, y) for i, y in enumerate(A)]

# y = x + b
# b = y - x
b_list = [y - x for x, y in points]
b_list.sort(reverse=True)

max_b = b_list[0]
min_b = b_list[-1]

best_ind = len(b_list)//2

minimum = calc_sadness(points, b_list[best_ind])

print(minimum)
n,m=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(m)]
x,y=0,0
cnt=['?']+[0]*n
for i in lst:
  if i[1]=='WA':
    if cnt[i[0]]!='AC':
      y+=1
  elif i[1]=='AC':
    cnt[i[0]]='AC'

x=cnt.count('AC')

print(x,y)

### FIXED CODE ###

n,m=map(int,input().split())
lst=[list(input().split()) for i in range(m)]
x,y=0,0
cnt=['?']+[0]*n
cnt2=[0]+[0]*n
for i in lst:
  if i[1]=='WA':
    pin=int(i[0])
    if cnt[pin]!='AC':
      cnt2[pin]+=1
  elif i[1]=='AC':
    cnt[int(i[0])]='AC'

x=cnt.count('AC')

for i in range(len(cnt)):
  if cnt[i]=='AC':
    y+=cnt2[i]
print(x,y)
import sys
input = sys.stdin.readline
from collections import deque

s = deque(input())
reverse = 0
q = int(input())

for _ in range(q):
  query = input()
  if query == '1':
    reverse = 1 - reverse
  else:
    _,f,c = query.split()
    if f == '1':
      if reverse:
        s.appendleft(c)
      else:
        s.append(c)
    else:
      if reverse:
        s.append(c)
      else:
        s.appendleft(c)
if not  reverse:
  s.reverse()

print(''.join(s))

### FIXED CODE ###

from collections import deque

s = deque(input())
reverse = 0
q = int(input())

for _ in range(q):
  query = input()
  if query == '1':
    reverse = 1 - reverse
  else:
    _,f,c = query.split()
    if f == '1':
      if reverse:
        s.append(c)
      else:
        s.appendleft(c)
    else:
      if reverse:
        s.appendleft(c)
      else:
        s.append(c)
        
  
if reverse:
  s.reverse()

print(''.join(s))
W=input().lower()
T=''
while 1:
 a=input().lower()+' '
 if'END_OF_TEXT '==a:break
 T+=a
print(T.count(W))

### FIXED CODE ###

import sys
W=input()
print(sys.stdin.read().lower().split().count(W))
from itertools import permutations as p

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

j = 1

for i in p(range(1, N + 1)):
  if i == P: a = j
  elif i == Q: b = j
  j += 1

if a - b >= 0: print(a - b)
else: print(b - a)  

### FIXED CODE ###

from itertools import permutations as p

N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

j = 0

for i in p(range(1, N + 1)):
  j += 1
  if i == P: a = j
  if i == Q: b = j

if a - b >= 0: print(a - b)
else: print(b - a)
h,w = map(int,input().split())
a_list = [input() for nesya in range(h)]

gyo = [False]*h
retsu = [False]*w
for i in range(h):
  for j in range(w):
    if a_list[i][j] == '#':
      gyo[i] = True
      retsu[j] = True
for k range(h):
  if gyo[k]:
    for l in range(w):
      if retsu[l]:
        print(a_list[k][l], end='')
    print()

### FIXED CODE ###

h,w = map(int,input().split())
a_list = [input() for nesya in range(h)]

gyo = [False]*h
retsu = [False]*w
for i in range(h):
  for j in range(w):
    if a_list[i][j] == '#':
      gyo[i] = True
      retsu[j] = True
for k in range(h):
  if gyo[k]:
    for l in range(w):
      if retsu[l]:
        print(a_list[k][l], end='')
    print()
4
1 2 3 4

### FIXED CODE ###

import numpy as np


N = int(input())
H = np.array(list(map(int, input().split())))

answer = 0

L1 = (H[:-1] >= H[1:])
#print(L1)

answer = 0
count = 0
for l in L1:
    if l:
        count += 1
    else:
        answer = max(answer, count)
        count = 0

print(max(answer, count))
def main(n):
	n = input()
	r = 0
	f = n[0]
	if(f =="0"):
		# zero mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="1"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="0"):
					r+=1
	else:
		# one mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="0"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="1"):
					r+=1
	# sum(result)
	return r

print(main(input()))
#assert(1 == main("000"))
#assert(3 == main("10010010"))
#assert(0 == main("0"))

### FIXED CODE ###

def main(n):
	r = 0
	f = n[0]
	if(f =="0"):
		# zero mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="1"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="0"):
					r+=1
	else:
		# one mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="0"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="1"):
					r+=1
	# sum(result)
	return r

print(main(input()))
#assert(1 == main("000"))
#assert(3 == main("10010010"))
#assert(0 == main("0"))
# スペース区切りの整数の入力
p,q,r = map(int, input().split(' '))

# 出力
Print(p+q+r-max(p, q, r))

### FIXED CODE ###

p,q,r=map(int,input().split())
print(p+q+r-max(p,q,r))
n,m=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(n-1):
  l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:m-1])
print(x[m-1]-x[0]-cnt)

### FIXED CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(m-1):
  l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:n-1])
print(sum(l)-cnt)
import sys
n = int(input())
a = [0] + list(map(int, input().split()))
if n == 2:
	print(-1)
	sys.exit()
used = [False for _ in range(n+1)]
hate = dict()
for x in a[1:]:
	if x in hate:
		hate[x] += 1
	else:
		hate[x] = 1
cur = 1
ng = 0
ans = []
while len(ans) < n:
	if len(hate) == 2:
		worst = False
		for k, v in hate.items():
			if v == n - len(ans) - 1:
				worst = k
				break
		if worst:
			ans.append(k)
			used[k] = True
			ng = a[k]
			hate[a[k]] -= 1
			if hate[a[k]] == 0:
				del hate[a[k]]
			continue

	while used[cur]:
		cur += 1

	if cur == ng:
		cur_copy = cur+1
		while used[cur_copy]:
			cur_copy += 1
		ans.append(cur_copy)
		used[cur_copy] = True
		ng = a[cur_copy]
		hate[ng] -= 1
		if hate[ng] == 0:
			del hate[ng]
	else:
		ans.append(cur)
		used[cur] = True
		ng = a[cur]
		hate[ng] -= 1
		if hate[ng] == 0:
			del hate[ng]

print(*ans)

### FIXED CODE ###

import sys
from itertools import permutations
n = int(input())
a = [0] + list(map(int, input().split()))
if n == 2:
	print(-1)
	sys.exit()
used = [False for _ in range(n+1)]
hate = dict()
for x in a[1:]:
	if x in hate:
		hate[x] += 1
	else:
		hate[x] = 1
cur = 1
ng = 0
ans = []
while len(ans) < n-3:
	if len(hate) == 2:
		worst = False
		for k, v in hate.items():
			if v == n - len(ans) - 1 and not used[k]:
				worst = k
				break
		if worst:
			ans.append(k)
			used[k] = True
			ng = a[k]
			hate[a[k]] -= 1
			if hate[a[k]] == 0:
				del hate[a[k]]
			continue

	while used[cur]:
		cur += 1

	if cur == ng:
		cur_copy = cur+1
		while used[cur_copy]:
			cur_copy += 1
		ans.append(cur_copy)
		used[cur_copy] = True
		ng = a[cur_copy]
		hate[ng] -= 1
		if hate[ng] == 0:
			del hate[ng]
	else:
		ans.append(cur)
		used[cur] = True
		ng = a[cur]
		hate[ng] -= 1
		if hate[ng] == 0:
			del hate[ng]

yet = [i for i in range(1, n+1) if not used[i]]
for p in permutations(yet):
	if p[0] != ng and p[1] != a[p[0]] and p[2] != a[p[1]]:
		ans += list(p)
		break

print(*ans)
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    ave=float(k/2)
    ans=n
    dis=abs(ans-k)
    if n>=k:
        ans=n%k
        if k>=ans:
            print(k%ans)
            exit()
    print(n if n<ave else k-n)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    if n>=k:
        n%=k
        print(k%n if n!=0 else 0)
        exit()    
    print(n if n<=k//2 else k-n)



if __name__ == "__main__":
    main()
a, b = map(int, input().split())
     
    ans=a+b
     
    if ans>=24 :
      ans=ans-24
      
    print(ans)

### FIXED CODE ###

a,b=map(int,input().split())

m=a+b

if m>=24:
  print(int(m-24))
else:
  print(int(m))
h, w = map(int, input().split())
arr = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    arr[i] = list(input())

def isWay(x, y):
    if x >= 0 and x < w and y >= 0 and y < h and arr[x][y] == '.':
        return True
    else:
        return False

numWay = 0
for i in range(h):
    for j in range(w):
        if arr[i][j] == '.':
            numWay += 1

queue = [[0, 0]]
arr[0][0] = 1
while 1:
    if len(queue) == 0:
        break
    cell = queue[0]
    queue.pop(0)
    x = cell[0]
    y = cell[1]
    n = arr[x][y]
    if(isWay(x-1, y)):
        arr[x-1][y] = n+1
        queue.append([x-1, y])
    if(isWay(x+1, y)):
        arr[x+1][y] = n+1
        queue.append([x+1, y])
    if(isWay(x, y-1)):
        arr[x][y-1] = n+1
        queue.append([x, y-1])
    if(isWay(x, y+1)):
        arr[x][y+1] = n+1
        queue.append([x, y+1])
print(numWay - arr[w-1][h-1])

### FIXED CODE ###

h, w = map(int, input().split())
arr = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    arr[i] = list(input())

def isWay(x, y):
    if x >= 0 and x < h and y >= 0 and y < w and arr[x][y] == '.':
        return True
    else:
        return False

numWay = 0
for i in range(h):
    for j in range(w):
        if arr[i][j] == '.':
            numWay += 1

queue = [[0, 0]]
arr[0][0] = 1
while 1:
    if len(queue) == 0:
        break
    cell = queue[0]
    queue.pop(0)
    x = cell[0]
    y = cell[1]
    n = arr[x][y]
    if(isWay(x-1, y)):
        arr[x-1][y] = n+1
        queue.append([x-1, y])
    if(isWay(x+1, y)):
        arr[x+1][y] = n+1
        queue.append([x+1, y])
    if(isWay(x, y-1)):
        arr[x][y-1] = n+1
        queue.append([x, y-1])
    if(isWay(x, y+1)):
        arr[x][y+1] = n+1
        queue.append([x, y+1])
if arr[h-1][w-1] == '.':
    print(-1)
else:
    print(numWay - arr[h-1][w-1])
N = int(input())
A = list(sorted(map(int, input().split())))
B = list(sorted(map(int, input().split()))
C = list(sorted(map(int, input().split())))

import bisect
upper_condtion = [bisect.bisect_left(A, b) for b in B]
lower_condition = [N - bisect.bisect_right(C, b) for b in B]

print(sum(map(lambda x: x[0]*x[1], zip(upper_condition, lower_condition))))

### FIXED CODE ###

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

import bisect
upper_condition = [bisect.bisect_left(A, b) for b in B]
lower_condition = [N - bisect.bisect_right(C, b) for b in B]

print(sum(map(lambda x: x[0]*x[1], zip(upper_condition, lower_condition))))
S = input()                 
count = 0
j=0
num=[]
for i in range(len(S)):
    # for j in range(4):
    #     if S[i]==ATCG[j]:
    if S[i] == 'A' or S[i]=='T' or S[i]=='C' or S[i]== 'G':
        count=count+1
        #print(S[i])
    else:
        num.append(count)
        j=j+1

max_num=max(num)
print(max_num)



### FIXED CODE ###

S = input()
S = S +'R'
#ATCG = 'ATCG'                   
count = 0
j=0
num=[]
for i in range(len(S)):
    # for j in range(4):
    #     if S[i]==ATCG[j]:
    # if (S[i] == 'A' or S[i]=='T' or S[i]=='C' or S[i]== 'G') and (i==(len(S)-1)):
    #     count =count+1
    #     print(S[i])
    #     num.append(count)

    if S[i] == 'A' or S[i]=='T' or S[i]=='C' or S[i]== 'G':
        count=count+1
        #print(S[i])
       
    else:
        num.append(count)
        j=j+1
        count=0


#print(num)
max_num=max(num)
print(max_num)
from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = [input() for _ in range(h)]
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            cnt = 0
            q = deque([(i, j, cnt)])
            v = set()
            while q:
                ii, jj, cnt = q.popleft()
                v.add((ii, jj))
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
    return ret


if __name__ == '__main__':
    main()


### FIXED CODE ###

c = input()
print(chr(ord(c) + 1))
S,T = open(0)

if T.startswith(S):
  print("Yes")
  
else:
  primt("No")


### FIXED CODE ###

S = str(input())
T = str(input())

if T.startswith(S):
  print("Yes")
else:
  print("No")
import sys
input()
print(len(1 for x in map(int,sys.stdin)if 2 in[x,pow(2,x,x)]))


### FIXED CODE ###

import sys
input()
def s():print(sum(2 in[x,pow(2,x,x)]for x in map(int,sys.stdin.readlines())))
if'__main__'==__name__:s()
import itertools as itool
N=int(input())
plist=list(map(int, input().split()))
qlist=list(map(int, input().split()))
mylist=list(itool.permutations(range(1,n+1)))
print(abs(mylist.index(p)-mylist.index(q)))


### FIXED CODE ###

import itertools as itool
N=int(input())
plist=list(map(int, input().split()))
qlist=list(map(int, input().split()))
mylist=list(itool.permutations(range(1,N+1)))

print(abs(mylist.index(tuple(plist))-mylist.index(tuple(qlist))))
n = int(input())
k = int(input())
s = input()
l = s.count('L')
r = s.count('R')
now = 0
for i in range(len(s)-1):
  if s[i] == 'R' and s[i+1] == 'L':
    now += 1
print(min(now + K, min(l, r)))

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
grp = 0
now = ""
for c in s:
  if c != now:
    grp += 1
    now = c
hap = 0
for i in range(n):
  if (i>0 and s[i]=='L' and s[i-1]=='L') or (i<n-1 and s[i]=='R' and s[i+1]=='R'):
    hap += 1
p_2 = (grp - 1) // 2
p_1 = (grp + 1) % 2
print(hap + 2 * min(k, p_2) + int(k > p_2) * p_1)
def build_stairs(N=N, HN=HN):
    if N == 1:
        return "Yes"
    for n in range(N-1):
        if HN[n] - HN[n+1] > 1:
            return "No"
        elif HN[n] - HN[n+1] == 1:
            HN[n+1] += 1
        if HN[n] < HN[n+1]:
            continue
    return "Yes"

N = int(input())
HN = input().split()
HN = [int(i) for i in HN]
ans = build_stairs(N, HN)
print(ans)
print("")

### FIXED CODE ###

N = int(input())
HN = input().split()

def build_stairs(N=N, HN=HN):
    if N == 1:
        return "Yes"
    for n in range(N-1):
        if HN[n] - HN[n+1] > 1:
            return "No"
        elif HN[n] - HN[n+1] == 1:
            HN[n+1] += 1
        if HN[n] < HN[n+1]:
            continue
    return "Yes"

HN = [int(i) for i in HN]
ans = build_stairs(N, HN)
print(ans)
print("")
import sys
for line in sys.stdin:
    p = line.strip('\n').index(' ')
    a,b = line[:p],line[p+1:]
    a,b = int(a),int(b)
    print '%d %d %.12f' %(a/b, a%b, 1.0*a/b)

### FIXED CODE ###

a, b = map(int, raw_input().split())
print '%d %d %.12f' %(a/b, a%b, 1.0*a/b)
n=int(input().split()[0])
print(join(sorted([input()for _ in[0]*n])))

### FIXED CODE ###

n=int(input().split()[0])
print(''.join(sorted([input()for _ in[0]*n])))
#!/usr/bin/env python3


def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))
    X = max(x)
    dp = [[[0]*(N*X +1) for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0] = 1
    for j in range(1,N+1):
        for k in range(N+1):
            for s in range(N*X+1):
                if s >= x[j-1] and k >= 1:
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
                else:# x[j]を選ぶと合計sにできない
                    dp[j][k][s] = dp[j-1][k][s]
    ans = 0
    for i in range(N):
        ans += dp[N][i+1][(i+1)*A]
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3


def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))
    X = 50
    dp = [[[0]*(N*X +1) for _ in range(N+1)] for _ in range(N+1)]
    dp[0][0][0] = 1
    for j in range(1,N+1):
        for k in range(N+1):
            for s in range(N*X+1):
                if s >= x[j-1] and k >= 1:
                    dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
                else:# x[j]を選ぶと合計sにできない
                    dp[j][k][s] = dp[j-1][k][s]
    ans = 0
    for i in range(N):
        ans += dp[N][i+1][(i+1)*A]
    print(ans)

if __name__ == "__main__":
    main()
import itertools
N,M,X=map(int, input().split())
List=[list(map(int,input().split())) for i in range(N)]

flag=True
i=1
champ=100000
total_cost=100000
while flag:
    newlist=list(itertools.combinations(range(N),i))
    for j in range(len(newlist)):
        for s in range(1,M+1):
            if sum(List[t][s] for t in newlist[j])<X:
                flag2=False
                break
        if flag2!=False:    
            total_cost=sum(List[t][0] for t in newlist[j])
        if total_cost<champ:
            champ=total_cost
        flag2=True
    if champ!=100000:
        print(champ)
        flag=False
        break
    i=i+1
    if i==N+1:
        break

if flag:    
    print(-1)

### FIXED CODE ###

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



ans=10000000000000
for j in range(1,2**(N+1)-1):
    combinationlist=list(map(int, [i for i in format(2**(N+1)+j,'b')]))
    del combinationlist[0]
    sumoflist=[sum(combinationlist[s]*List[s][k] for s in range(N)) for k in range(M+1)]
    flag=True
    for t in range(1,M+1):
        if sumoflist[t]<X:
            flag=False
            break
    if flag and sumoflist[0]<ans:
        ans=sumoflist[0]

if ans!=10000000000000:
    print(ans)
else:
    print(-1)
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = [0] * n
c[0] = 1
m = 0
while c[b-1] < 2 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	k -= 1
while c[b-1] < 3 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	m += 1
o = k % m
for i in range(o):
	b = a[b-1]
print(b)

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = [0] * n
c[0] = 1
m = 0
while c[b-1] < 2 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	k -= 1
while c[b-1] < 3 and k > 0:
	b = a[b-1]
	c[b-1] += 1
	m += 1
if k == 0:
	print(b)
else:
	o = k % m
	for i in range(o):
		b = a[b-1]
	print(b)