You are given a string $t$ consisting of $n$ lowercase Latin letters and an integer number $k$.

Let's define a substring of some string $s$ with indices from $l$ to $r$ as $s[l \dots r]$.

Your task is to construct such string $s$ of minimum possible length that there are exactly $k$ positions $i$ such that $s[i \dots i + n - 1] = t$. In other words, your task is to construct such string $s$ of minimum possible length that there are exactly $k$ substrings of $s$ equal to $t$.

It is guaranteed that the answer is always unique.


-----Input-----

The first line of the input contains two integers $n$ and $k$ ($1 \le n, k \le 50$) — the length of the string $t$ and the number of substrings.

The second line of the input contains the string $t$ consisting of exactly $n$ lowercase Latin letters.


-----Output-----

Print such string $s$ of minimum possible length that there are exactly $k$ substrings of $s$ equal to $t$.

It is guaranteed that the answer is always unique.


-----Examples-----
Input
3 4
aba

Output
ababababa

Input
3 2
cat

Output
catcat

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Implementation


Solutions:
(n, k) = map(int, input().split())
x = input()
flag = False
for i in range(n - 1, 0, -1):
	if x[:i] == x[n - i:]:
		flag = True
		print(x, end='', sep='')
		for j in range(k - 1):
			print(x[i:], end='', sep='')
		break
if flag:
	pass
else:
	print(x * k)


(n, k) = map(int, input().split())
t = input()
(left, right) = (0, 0)
s = ''
for i in range(1, n):
	if t[i] == t[left]:
		for right in range(i, n):
			if t[right] != t[left]:
				left = 0
				break
			left += 1
		if left != 0 and right == n - 1:
			s = t[left:]
			break
if s == '':
	s = t
for i in range(k - 1):
	t += s
print(t)


(n, k) = map(int, input().split())
t = input()
for i in range(1, len(t) + 1):
	if len(t) % i != 0:
		continue
	substr = t[:i]
	times = int(len(t) / i)
	ist = substr * times
	if ist == t:
		break
if 1 < len(ist):
	for i in range(len(ist) - 1, 0, -1):
		if ist[len(ist) - i:len(ist)] == ist[0:i]:
			ist = ist[0:len(ist) - i]
			break
print(ist * (k - 1) + t)


(n, k) = list(map(int, input().split()))
t = input()
for i in range(1, n):
	if t[i:] == t[:n - i]:
		print(t + t[n - i:] * (k - 1))
		break
else:
	print(t * k)


(n, k) = [int(x) for x in input().rstrip().split()]
a = input()
i = 1
while a[i:] != a[:-i]:
	i += 1
print(a[:i] * k + a[i:])


inp1 = input().split()
n = int(inp1[0])
k = int(inp1[1])
s = input()

def isGood(l):
	if l == 0:
		return True
	s1 = s[0:l]
	s2 = s[n - l:n]
	return s1 == s2
maxMatch = 0
for i in range(n - 1, 0, -1):
	if isGood(i):
		maxMatch = i
		break
ans = ''
for i in range(k):
	if i == 0:
		ans += s
	else:
		ans += s[maxMatch:n]
print(ans)


(n, k) = map(int, input().split())
s = input()
s1 = s
s2 = ''
for i in range(n // 2, 0, -1):
	if s[:i] == s[-i:]:
		s1 = s[:-i]
		s2 = s[-i:]
		break
res = s1 * k + s2
count = 1
pos = res.find(s)
while count < k:
	pos = res.find(s, pos + 1)
	count += 1
print(res[:pos + len(s)])


(length_t, num_sub_strings) = map(int, input().split())
t = input()
repeat = length_t
for pos in range(1, length_t):
	if t[pos:] == t[:length_t - pos]:
		repeat = pos
		break
if repeat == length_t:
	print(''.join([t] * num_sub_strings))
else:
	solution = [t]
	suffix = t[-repeat:]
	solution.extend(suffix * (num_sub_strings - 1))
	print(''.join(solution))


import re
(n, k) = map(int, input().split())
s = input()
res = [s * k]
for i in range(n, 0, -1):
	if s == (s[:i] * ((n + i - 1) // i))[:n]:
		res.append(s[:i] * (k - 1) + s)
print(min(res, key=lambda s: len(s)))


(n, k) = map(int, input().split())
s = input()
s1 = s
c = 0
for i in range(len(s) - 1):
	if s[:i + 1] == s[n - i - 1:]:
		c = i + 1
for i in range(k - 1):
	s1 += s[c:]
print(s1)


(n, k) = map(int, input().split())
s = input()
for i in range(1, n + 1):
	if s in s[i:] + s[-i:]:
		ans = i
		break
print(s, end='')
for i in range(k - 1):
	print(s[-ans:], end='')


from math import ceil

def prefix_function(s, n):
	for i in range(0, n - 1):
		s1 = s[0:i + 1]
		s2 = s1 * ceil(n / len(s1))
		try:
			if s2.index(s) == 0:
				return s1
		except:
			pass
	return s
(n, k) = [int(x) for x in input().split()]
t = input()
p = prefix_function(t, n)
print(p * (k - 1), t, sep='')


def solve():
	(n, k) = [int(x) for x in input().split(' ')]
	t = input()
	j = 0
	for i in range(1, n):
		if t[:i] == t[-i:]:
			j = i
	s = t + (k - 1) * t[-(n - j):]
	return s
print(solve())


(n, k) = map(int, input().split())
s = input()
s1 = s
t1 = ''
for i in range(n - 1):
	s = s1 + s1[n - i - 1:]
	if s[:n] == s[i + 1:]:
		t1 = s1[n - i - 1:]
		break
if t1 == '':
	t1 = s1
print(s1 + (k - 1) * t1)


def connection(txt1, txt2):
	ref1 = []
	ref2 = []
	for i in range(len(txt1) - 1, -1, -1):
		ref1.append(hash(txt1[i:]))
	for j in range(1, len(txt2) + 1):
		ref2.append(hash(txt2[0:j]))
	ans = []
	try:
		i = 0
		while True:
			if ref1[i] == ref2[i]:
				ans.append(len(txt1) - i - 1)
			i += 1
	except IndexError:
		pass
	ans.sort()
	for item in ans:
		if item != 0:
			return item
	return -1
(n, k) = map(int, input().split())
txt = input()
ans = connection(txt, txt)
if ans != -1:
	print(txt + txt[len(txt) - ans:] * (k - 1))
else:
	print(txt * k)


(n, k) = map(int, input().split())
t = input()
ans = t
for i in range(1, k):
	idx = 0
	for j in range(1, n):
		if ans[-j:] == t[:j]:
			idx = j
	ans += t[idx:]
print(ans)


(n, k) = map(int, input().split())
t = input()
a = ''
for i in range(1, n):
	if str(t[:n - i]) == str(t[i:]):
		a = t[n - i:]
		break
if a == '':
	print(t * k)
else:
	print(t + a * (k - 1))


(n, k) = [int(c) for c in input().split()]
s = input()
flag = 1
first = s[0]
for i in range(1, n):
	if s[i] != first:
		flag = 0
		break
str_added = ''
c = 1
if flag == 0:
	while c < n:
		if s[0] == s[c]:
			if s[c:n] == s[0:n - c]:
				str_added = s[n - c:n]
				break
			else:
				c += 1
		else:
			c += 1
else:
	str_added = first
if len(str_added) == 0:
	str_added = s
for i in range(k - 1):
	s += str_added
print(s)


(n, k) = map(int, input().strip().split())
s = input()
isbegining = False
for j in range(1, n):
	start = j
	isbegining = True
	c = 0
	for i in range(j, n):
		if s[i] != s[c]:
			isbegining = False
			break
		c += 1
	if isbegining == True:
		break
if isbegining == True:
	repeat = s[n - start:]
else:
	repeat = s
print(s, end='')
for i in range(k - 1):
	print(repeat, end='')


(n, k) = map(int, input().split())
s = input()
t = n - 1
while s[:t] != s[-t:]:
	t -= 1
k = k - 1 if t else k - 2
print(s + s[t:] * k)


A = list(map(int, input().split()))
str = input()
z = 0
n = int(A[0])
k = int(A[1])
for i in range(1, n + 1):
	if str[i:] == str[:n - i]:
		ans = str + (k - 1) * str[n - i:]
		break
print(ans)


(n, k) = map(int, input().split())
s = input()
k -= 1
ans = s
l = n
for i in range(k):
	for j in range(l - n + 1, l):
		if ans[j:] == s[:l - j]:
			ans += s[l - j:]
			l += n - (l - j)
			break
	else:
		ans += s
		l += n
print(ans)


(n, k) = map(int, input().split())
s = input()
i = 1
while s[i:] != s[:-i]:
	i += 1
print(s[:i] * int(k) + s[i:])


def getNext(pattern):
	next1 = []
	j = 0
	plen = len(pattern)
	next1.append(0)
	for i in range(1, plen):
		while j > 0 and pattern[j] != pattern[i]:
			j = next1[j - 1]
		if pattern[i] == pattern[j]:
			j = j + 1
		next1.append(j)
	return next1
(m, s) = list(map(int, input().split()))
l = input()
n = getNext(l)[-1]
print(l + l[n:] * (s - 1))


(n, k) = map(int, input().split())
t = input()
pos = min(filter(lambda x: t[x:] == t[:-x] or x == n, range(n + 1)))
print(t + t[n - pos:] * (k - 1))


(n, k) = map(int, input().split())
s = input()
check = 0
r = n - 1
l = 0
while r > 0:
	if s[:l + 1] == s[r:]:
		check = l + 1
	r -= 1
	l += 1
if check == 0:
	print(s * k)
else:
	print(s + s[check:] * (k - 1))


import sys
from itertools import accumulate

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')
INF = 10 ** 18
MOD = 10 ** 9 + 7
(N, K) = MAP()
T = input()
if set(T) == 1:
	ans = T + T[0] * (K - 1)
	print(ans)
	exit()
i = N - 1
while T[:i] != T[N - i:]:
	i -= 1
same = T[:i]
diff = T[i:]
ans = same + diff * K
print(ans)


import math

def longestPrefixSuffix(s, s1):
	n = s1
	if n < 2:
		return 0
	le = 0
	i = n // 2
	while i < n:
		if s[i] == s[le]:
			le += 1
			i += 1
		elif le == 0:
			i += 1
		else:
			le -= 1
	return le
n = input().split(' ')
k = input()
ans = k
end = 0
for i in range(1, len(k)):
	if k[:i] == k[len(k) - i:]:
		end = i
for i in range(int(n[1]) - 1):
	ans += k[end:]
print(ans)


(n, k) = map(int, input().split())
t = input()
s = ''
while k > 0:
	i = n - 1
	while i > 0 and (not s.endswith(t[:i])):
		i -= 1
	s += t[i:]
	k -= 1
print(s)


(n, k) = map(int, input().split())
t = input()
i = 1
while t[i:] != t[:-i]:
	i += 1
print(t[:i] * k + t[i:])


(n, k) = map(int, input().split())
t = input()
x = t
count = 0
for i in range(1, n):
	if t[0:i] == t[n - i:n]:
		count = i
for i in range(k - 1):
	x += t[count:]
print(x)


def prefix(s):
	v = [0] * len(s)
	for i in range(1, len(s)):
		k = v[i - 1]
		while k > 0 and s[k] != s[i]:
			k = v[k - 1]
		if s[k] == s[i]:
			k += 1
		v[i] = k
	return v
s = input()
(n, k) = s.split(' ')
n = int(n)
k = int(k)
s = input()
pi = prefix(s)
l = len(s) - pi[n - 1]
i = 0
while i < k - 1:
	print(s[:l], end='')
	i += 1
print(s)


(n, k) = map(int, input().split())
s = input()
a = 1
while a <= n and s.find(s[a:]):
	a += 1
print(s[:a] * (k - 1) + s)


(n, k) = list(map(int, input().split()))
t = list(input())
for i in range(1, n + 1):
	if t[i:] == t[:n - i]:
		s = t[:i] * k
		s += t[i:]
		break
print(''.join(s))


from collections import deque
from sys import stdin
lines = deque((line.strip() for line in stdin.readlines()))

def nextline():
	return lines.popleft()

def types(cast, sep=None):
	return tuple((cast(x) for x in strs(sep=sep)))

def ints(sep=None):
	return types(int, sep=sep)

def strs(sep=None):
	return tuple(nextline()) if sep == '' else tuple(nextline().split(sep=sep))

def main():
	(_, k) = ints()
	s = nextline()
	for i in range(len(s) - 1, 0, -1):
		if s.endswith(s[:i]):
			add = s[i:]
			break
	else:
		add = s
	print(s + add * (k - 1))
main()


(n, k) = [int(i) for i in input().split()]
t = input()
s = t
found = 0
for idx in range(len(t) - 1):
	if t[:idx + 1] == t[len(t) - 1 - idx:]:
		if idx + 1 > found:
			found = idx + 1
t = t[found:]
for i in range(k - 1):
	s += t
print(s)


(n, m) = map(int, input().split())
s = input()
reps = s
for i in range(1, n):
	if s[:i] == s[-i:]:
		reps = s[:-i]
for i in range(m - 1):
	print(reps, end='')
print(s)


(n, k) = map(int, input().split())
p = input()
e = 0
if n == 1:
	print(p * k)
else:
	oo = p
	for i in range(n - 1):
		if p[n - 1 - i:n] == p[:i + 1]:
			e = i + 1
	oo = oo + p[e:] * (k - 1)
	print(oo)


(n, k) = map(int, input().split())
s = input()
dp = [0] * n
match = 0
for i in range(1, n):
	while match and s[i] != s[match]:
		match = dp[match - 1]
	match += s[i] == s[match]
	dp[i] = match
print(s + s[dp[-1]:] * (k - 1))


def p(t, n):
	out = 0
	if n == 1:
		return 0
	for i in range(1, n):
		t1 = t[:i]
		t2 = t[n - i:]
		if t1 == t2:
			out = max([out, len(t1)])
	return out
inp = input('').split()
n = int(inp[0])
k = int(inp[1])
t = input('')
x = p(t, n)
ans = t + t[x:] * (k - 1)
print(ans)


(n, k) = map(int, input().split())
t1 = input()
t = t1
for x in range(k - 1):
	i = len(t1) - 1
	while t[-i:] != t1[:i]:
		i -= 1
	t += t1[i:]
print(t)


(n, k) = input().split()
s = input()
col = 0
n = int(n)
for i in range(1, int(n)):
	if s[0:i] == s[n - i:n]:
		col = i
print(s + s[col:] * (int(k) - 1))


(n, k) = map(int, input().split())
s = str(input())
t = 1
while t < n and s[t:] != s[:-t]:
	t = t + 1
print(s[:t] * k + s[t:])


(n, k) = [int(i) for i in input().split()]
t = input()
i = 1
while t[i:] != t[:-i]:
	i += 1
print(t[:i] * k + t[i:])


(n, kk) = map(int, input().split())
s = input()
if s == s[::-1] or s != s[::-1]:
	k = ''
	l = 0
	for i in reversed(range(1, n)):
		k = s[i] + k
		if s.startswith(k):
			l = len(k)
	ss = s[l:]
	fs = s + ss * (kk - 1)
	print(fs)


str_1 = input()
str_2 = input()
num_list = str_1.split()
n = int(num_list[0])
k = int(num_list[1])
str_3 = str_2
for j in range(n - 1):
	if str_2[0:n - j - 1] == str_2[j + 1:n]:
		str_3 = str_2[n - j - 1:n]
		break
print(str_2 + str_3 * (k - 1))


(n, k) = list(map(int, input().split()))
t = input()
step = 1
for i in range(1, n):
	j = i
	while j < n and t[j] == t[j - step]:
		j += 1
	if j == n:
		break
	step = i + 1
mod = n % step
print(t + (k - 1) * t[mod:mod + step])


(n, k) = map(int, input().split())
st = input()
ans = st
t = 0
for i in range(1, n):
	if st[:i] == st[n - i:]:
		t = i
for i in range(k - 1):
	ans += st[t:]
print(ans)


def foo(s):
	if len(s) == 1:
		return s
	for i in range(1, len(s)):
		if s.startswith(s[i:]):
			return s[len(s) - i:]
	return s
(n, k) = [int(x) for x in input().split()]
t = input()
print(t + foo(t) * (k - 1))


(n, k) = map(int, input().split())
s = input()
for i in range(1, len(s)):
	if s[i:] == s[:len(s) - i]:
		print(s + (k - 1) * s[len(s) - i:])
		exit()
print(s * k)


def readints():
	return [int(val) for val in input().strip().split()]

def main():
	(n, m) = readints()
	s = input().strip()
	max_prefix = 0
	for i in range(1, n):
		if s[i:] == s[:n - i]:
			max_prefix = n - i
			break
	add = s[max_prefix:]
	print(s + (m - 1) * add)
main()


(n, k) = map(int, input().split())
string = input()
i = n - 1
while string[:i] != string[-i:]:
	i -= 1
print(string + string[i:] * (k - 1))


r = input
(n, k) = map(int, r().split())
s = str(r())
(a, b) = ('', '')
x = -1
for i in range(n - 1, 0, -1):
	l = n - i
	if s[0:l] == s[i:]:
		x = l
if x == -1:
	add = s
else:
	add = s[x:]
for i in range(k - 1):
	s += add
print(s)


data = input().split()
k = int(data[1])
s_0 = list(input())
s = list()
h = 1
fl2 = True
for i in s_0:
	s.append(i)
k_was = 1
if len(s_0) == 1:
	for t in range(1, k):
		s.append(s_0[0])
	k_was = k + 10
while k_was < k:
	j = 0
	x = 0
	while not (h > len(s) - 1 or j > len(s_0) - 1):
		if s[h] == s_0[j]:
			if fl2:
				x = h
				fl2 = False
			j += 1
			fl1 = True
			h += 1
		else:
			if not fl2:
				h = x + 1
			else:
				h += 1
			fl2 = True
			fl1 = False
			j = 0
	if fl1:
		for p in range(x, x + len(s_0)):
			if p >= len(s):
				s.append(s_0[p - x])
			else:
				s[p] = s_0[p - x]
		h = x + 1
		j = 0
		k_was += 1
		fl2 = True
	else:
		for p in s_0:
			s.append(p)
		k_was += 1
		h = h + 1
		j = 0
		fl2 = True
f = ''
for t in range(0, len(s)):
	f += s[0]
	del s[0]
print(f)


(n, i) = map(int, input().split())
chuoi = input()

def thu_gon(chuoi):
	do_dai = len(chuoi)
	chuoi_ko_trung_lap = chuoi
	for i in range(1, do_dai):
		if chuoi[0:do_dai - i] == chuoi[i:]:
			chuoi_ko_trung_lap = chuoi[do_dai - i:]
			break
	return chuoi_ko_trung_lap
print(chuoi + (i - 1) * thu_gon(chuoi))


(n, k) = [int(num) for num in input().split(' ')]
string = input()

def fn(string, k):
	maximum_match = 0
	for i in range(1, len(string)):
		if string[:i] == string[-i:]:
			maximum_match = i
	answer = list(string)
	extra = list(string[maximum_match:])
	for i in range(k - 1):
		answer.extend(extra)
	return ''.join(answer)
print(fn(string, k))


(x, y) = [int(x) for x in input().split()]
s = input()
if x == 1:
	t = s * y
	print(t)
else:
	count = 0
	t = s
	for i in range(len(s)):
		if s[:i + 1] == s[-i - 1:]:
			count += 1
			if len(s[:-i - 1]) != 0:
				t = s[:-i - 1]
	if count == 0:
		print(s * y)
	else:
		print(t * (y - 1) + s)


(n, k) = map(int, input().split())
s = input()
print(s, end='')
l = 0
for i in range(1, n):
	if s[i:] == s[0:n - i]:
		l = len(s[i:])
		break
print(s[l:] * (k - 1))


def find_pos(s):
	for i in range(len(s)):
		if s[i:] == s[:-i]:
			return i
	return len(s)
line = input()
[n, k] = [int(w) for w in line.split(' ')]
s = input()
i = find_pos(s)
print(s[:i] * k + s[:len(s) - i])


def test_0():
	import math
	from collections import Counter
	(n, k) = list(map(int, input().split(' ')))
	m = input()
	a = 0
	for i in range(n):
		if m[0:i] == m[n - i:n]:
			a = i
	print(m[0:n - a] * k + m[0:a])
test_0()


(n, t) = map(int, input().split())
s = str(input())
size = n
for i in range(1, n):
	if s[i:] == s[:n - i]:
		size = i
		break
print(s + (t - 1) * s[n - size:])


(n, t) = map(int, input().split())
s = input()
k = 0
prRes = []
for i in s:
	prRes.append(0)
k = 0
for i in range(1, len(prRes)):
	while k != 0 and s[k] != s[i]:
		k = prRes[k - 1]
	if s[k] == s[i]:
		k += 1
	prRes[i] = k
if n == 1 or prRes[len(prRes) - 1] == 0:
	print(s * t)
else:
	cycle = s[:len(s) - prRes[len(prRes) - 1]]
	print(cycle * (t - 1) + s)


(n, m) = map(int, input().split(' '))
t = input()
i = 1
j = 0
k = i
while i < n:
	while k < n and t[j] == t[k]:
		k += 1
		j += 1
	if k == n:
		break
	i += 1
	j = 0
	k = i
print(t[0:j], end='')
for _ in range(m):
	print(t[j:n], end='')


(n, k) = map(int, input().split())
(t, i, temp) = (input(), 0, 0)
for i in range(n):
	if t.endswith(t[0:i]):
		temp = i
print(t + t[temp:] * (k - 1))


(n, k) = input().split()
n = int(n)
k = int(k)
t = input()
indicator = 0
length = 0
for i in range(n - 1):
	if t[i + 1:] == t[:n - i - 1]:
		indicator = 1
		length = n - i - 1
		break
print(t, t[length:] * (k - 1), sep='')


(n, k) = map(int, input().split())
s = input()
r = n
for i in range(1, n):
	r1 = n - i
	if s[:r1] == s[i:]:
		r = i
		break
cnt = s.count(s[r:])
if cnt > 1 and cnt * len(s[r:]) == n:
	print(s, end='')
	print(s[r:] * (k - 1))
else:
	print(s[:r] * k + s[r:])


i1 = input()
i2 = input()
i1 = i1.split(' ')
tam = int(i1[0])
repl = int(i1[1])
lv = 0
for i in range(1, tam + 1):
	cutOri = i2[:tam - int(i)]
	cutPast = i2[:i]
	nCad = cutOri + cutPast
	if nCad == i2 and i != tam:
		lv = i
nfinal = i2
for j in range(1, repl):
	part = i2[lv:]
	nfinal = nfinal + part
print(nfinal)


def longestPrefixSuffix(s):
	n = len(s)
	for res in range(n - 1, 0, -1):
		prefix = s[0:res]
		suffix = s[n - res:n]
		if prefix == suffix:
			return res
	return 0
r = input()
n = int(r.split()[0])
k = int(r.split()[1])
s = input()
long_s = longestPrefixSuffix(s)
print(s, end='')
for i in range(k - 1):
	print(s[long_s:], end='')
print()


(n, k) = [int(x) for x in input().split()]
s = input()
indx = 1
while indx < n and s[indx:] != s[:-indx]:
	indx += 1
print(s[:indx] * k + s[indx:])


import atexit, io, sys, collections, math, heapq, fractions, copy, os, functools
import sys
import random
import collections
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def f(s, k):
	j = -1
	for i in range(1, len(s)):
		if s[i:] == s[:len(s) - i]:
			j = i
			break
	if j == -1:
		return s * k
	rep = s[len(s) - j:]
	return s + rep * (k - 1)
(n, k) = map(int, input().split())
s = input()
print(f(s, k))


(n, k) = map(int, input().split())
s = input()
ind = 0
for i in range(1, n):
	if s[:i] == s[n - i:]:
		ind = i
res = s
for i in range(k - 1):
	res += s[ind:]
print(res)


def count_occurences(s, t, n, N):
	count = 0
	for i in range(0, N - n + 1):
		if s[i:i + n] == t:
			count += 1
	return count

def solution(t, n, k):
	for size in range(1, n + 1):
		ov = t[0:size]
		good = True
		for subs in range(n // size + 1):
			s2 = t[subs * size:(subs + 1) * size]
			if len(s2) == size:
				if ov != s2:
					good = False
					break
			else:
				for i in range(len(s2)):
					if s2[i] != ov[i]:
						good = False
						break
		if good:
			break
	s = ''
	ind = 0
	m = len(ov)
	while count_occurences(s, t, n, len(s)) != k:
		s += ov[ind % m]
		ind += 1
	print(s)
(n, m) = [int(val) for val in input().split()]
s = [str(val) for val in input().split()][0]
solution(s, n, m)


(n, k) = map(int, input().split())
S = input().rstrip()
for i in range(n - 1, -1, -1):
	pref = S[:i]
	suff = S[-i:]
	if pref == suff:
		print(S + S[i:] * (k - 1))
		break
else:
	print(S * k)


(n, k) = map(int, input().split())
s = input()
for i in range(n):
	if s.find(s[i + 1:]) == 0:
		break
print(s[:i + 1] * k + s[i + 1:])


i = 1
m = 1
try:
	iStr = input()
	t = input()
	ips = iStr.split()
	n = int(ips[0])
	k = int(ips[1])
except:
	k = 0
if k > 0 and n > 0 and (n == len(t)):
	j = n - 1
	flag = 0
	for count in range(0, n - 1):
		if t[:i] == t[j:]:
			iF = i
			flag = 1
		i += 1
		j -= 1
	final = t
	if flag == 1:
		for m in range(0, k - 1):
			final += t[iF:]
	else:
		for m in range(0, k - 1):
			final += t
	print(final)


(n, k) = map(int, input().split())
s = input()
t = str('')
for i in range(n - 1):
	if s[:i + 1] == s[n - 1 - i:]:
		t = s[:i + 1]
l = len(t)
print(s + (k - 1) * s[l:])


(n, k) = map(int, input().split())
t = input()
p = n - 1
while t[:p] != t[-p:]:
	p -= 1
print(t + t[p:] * (k - 1))


(n, k) = map(int, input().split(' '))
c = input()
j = 0
i = 1
while i < n:
	if c[j] == c[i]:
		j += 1
	else:
		i -= j
		j = 0
	i += 1
d = c
for i in range(k - 1):
	d += c[j:]
print(d)


(n, k) = list(map(int, input().split()))
s = input()
i = 1
while i < len(s) and s[i:] != s[:n - i]:
	i += 1
t = s[:i] * k + s[i:]
print(t)


def substring(string, m):
	cipher = string
	ajout = ''
	for i in range(1, len(string)):
		if string[i:] == string[:len(string) - i]:
			ajout = string[len(string) - i:]
			break
	if len(ajout) == 0:
		cipher += string * (m - 1)
	else:
		cipher = cipher + ajout * (m - 1)
	print(cipher)
n = list(map(int, input().split()))
m = n[1]
string = input()
substring(string, m)


(n, k) = map(int, input().split())
a = input()
ans = ''
for i in range(n - 1, 0, -1):
	if a[:i] == a[n - i:]:
		for j in range(k):
			ans = ans + a[:n - i]
		ans = ans + a[n - i:]
		print(ans)
		exit(0)
print(k * a)


(n, k) = map(int, input().split())
ans = input()
addit = 0
for i in range(1, n):
	if ans[0:i] == ans[n - i:n]:
		addit = i
print(ans + ans[addit:n] * (k - 1))


(n, k) = list(map(int, input().split()))
t = input()
for i in range(n - 1, -1, -1):
	if t[:i] == t[n - i:]:
		break
x = t[i:]
for j in range(k - 1):
	t = t + x
print(t)


(n, k) = map(int, input().split())
t = str(input())
rav = 0
new_t = t
for i in range(1, n):
	if new_t[:i] == t[n - i:]:
		rav = i
ans = t
ans += t[rav:] * (k - 1)
print(ans)


(n, k) = list(map(int, input().split()))
t = input()
cnt = 0
for i in range(1, n):
	cnt = 0
	for j in range(n - i):
		if t[j] == t[i + j]:
			cnt += 1
		else:
			break
	if cnt == n - i:
		cnt = i
		break
if cnt == 0:
	print(t * k)
	exit()
f = t[n - cnt:n]
res = t + (k - 1) * f
print(res)


k = int(input().split()[1])
t = input()
i = 1
while t[i:] != t[:-i]:
	i += 1
print(t[:i] * k + t[i:])


(n, k) = map(int, input().split())
s = input()
temp = 0
for i in range(1, len(s)):
	if s[:i] == s[-i:]:
		temp = i
ans = s + s[temp:] * (k - 1)
print(ans)


(n, k) = map(int, input().split())
t = input()
for j in range(n):
	if t[0:j] == t[n - j:n]:
		i = j
for _ in range(k - 1):
	print(t[:n - i], end='')
print(t)


(n, k) = list(map(int, input().split()))
s = input()
g = len(set(s))
s3 = s[:g] * int(n / g)
if s3 == s:
	print(s + s[:g] * (k - 1))
else:
	x = ''
	y = ''
	i = 0
	j = len(s) - 1
	t = []
	while i < n:
		x += s[i]
		y = s[j] + y
		if x == y:
			t.append(x)
		i += 1
		j -= 1
	if len(t) > 1:
		t.pop()
	h = len(t[-1])
	m = ''
	flag = 0
	for l in range(n):
		if l < h:
			pass
		else:
			flag = 1
			m += s[l]
	if flag == 0:
		m = s
	f = m * (k - 1)
	print(s + f)


read_numbers = lambda : map(int, input().split())
INF = 1 << 64
(n, k) = read_numbers()
s = input()
m = 0
for i in range(1, n):
	if s[:i] == s[-i:]:
		m = i
if m == 0:
	print(s * k)
else:
	print(s + s[m:] * (k - 1))


def solve(s, n):
	s = ''.join(s)
	n += 1
	count = n - 1
	for i in range(n - 1):
		if s[:count] == s[n - count:n]:
			break
		count -= 1
	return count

def make_table(pattern, unique):
	table = []
	k = 0
	current = []
	for i in range(len(pattern) + 1):
		current.append('')
	for i in pattern:
		table.append([])
		for j in unique:
			if i is not j:
				current[k] = j
				table[k].append(solve(current, k))
			else:
				table[k].append(k + 1)
		current[k] = pattern[k]
		k += 1
	table.append([])
	for j in unique:
		current[k] = j
		table[k].append(solve(current, k))
	return table

def find(text, table, d):
	count = 0
	current = 0
	k = 0
	for i in text:
		if i in d.keys():
			current = table[current][d[i]]
		else:
			current = 0
		if current == len(table) - 1:
			count += 1
		k += 1
	return count
(n, k) = map(int, input().split())
pattern = input().strip()
unique = set()
for i in pattern:
	unique.add(i)
unique = list(unique)
unique.sort()
table = make_table(pattern, unique)
d = {}
t = max(table[len(table) - 1]) - 1
ans = pattern[:]
k -= 1
for i in range(k):
	ans += pattern[t:]
print(ans)


(n, k) = map(int, input().split())
t = input()
cycle = n
for i in range(1, n):
	if t[i:] == t[:n - i]:
		cycle = i
		break
ans = t[:cycle] * k + t[cycle:]
print(ans)


from math import *
from collections import *
from itertools import *
from bisect import *
from operator import *
import sys
sys.setrecursionlimit(1000000)

def io():
	return map(int, input().split())

def op():
	return list(map(int, input().split()))

def o():
	return int(input())

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
p = input
(n, k) = io()
s = p()
m = 0
for i in range(1, n):
	fg = 1
	for j in range(0, i):
		if s[j] != s[n - i + j]:
			fg = 0
	if fg:
		m = i
print(s[:m] + s[m:] * k)


def main():
	(n, k) = map(int, input().split())
	t = input()
	for prefix_len in range(1, n + 1):
		if (t[:prefix_len] + t).startswith(t):
			prefix = t[:prefix_len]
			break
	print(prefix * (k - 1) + t)
main()


from math import floor
lol = input()
n = int(lol.split(' ')[0])
k = int(lol.split(' ')[1])
instr = input()
count = 0
for i in range(n):
	tocheck = instr[:i]
	checkwth = instr[n - i:n:1]
	if tocheck == checkwth:
		count = i
for i in range(k):
	print(instr[:n - count], end='')
print(instr[n - count:])


x = input()
x = x.split()
n = int(x[0])
k = int(x[1])
s = input()
pos = 0
for i in range(0, len(s)):
	for j in range(i + 1, len(s)):
		ii = 0
		jj = j
		while jj < len(s) and s[ii] == s[jj]:
			ii = ii + 1
			jj = jj + 1
		if jj == len(s):
			pos = j
			break
	if pos != 0:
		break
if pos == 0:
	pos = len(s)
print(s, end='')
for i in range(0, k - 1):
	for j in range(len(s) - pos, len(s)):
		print(s[j], end='')
print()


def isPal(s):
	return s == s[::-1]

def solve(t, n, k):
	i = 1
	while i < n and t[i:] != t[:-i]:
		i += 1
	print(t[:i] * k + t[i:])
(n, k) = map(int, input().split())
s = str(input())
solve(s, n, k)


(n, k) = [int(x) for x in input().split()]
t = list(input())
charcom = 0
i = 1
while i < n:
	if t[:i] == t[n - i:]:
		charcom = 0
		charcom = len(t[:i])
	i += 1
s = []
s.append(''.join(t))
for i in range(k - 1):
	s[0] = s[0] + ''.join(t[charcom:])
print(''.join(s))


(N, K) = map(int, input().split())
S = input()
L = 0
for i in range(1, N):
	if S[i:] == S[:N - i]:
		L = N - i
		break
part = S[L:]
S += part * (K - 1)
print(S)


from math import *
(n, k) = map(int, input().split())
t = input()
if len(set(t)) == 1:
	res = t + t[0] * (k - 1)
elif t == t[::-1]:
	ch = t[0]
	cnt = 0
	for i in t:
		if i == ch:
			cnt += 1
		else:
			break
	res = t + t[cnt:] * (k - 1)
else:
	res = t * k
x = n - 1
while t[:x] != t[n - x:]:
	x -= 1
res1 = t + t[x:] * (k - 1)
if len(res) > len(res1):
	print(res1)
else:
	print(res)


ln = [int(i) for i in input().split(' ')]
n = ln[0]
k = ln[1]
st = list(input())
ind = -1
for i in range(1, len(st)):
	f = True
	for j in range(i, len(st)):
		if st[j] != st[j - i]:
			f = False
			break
	if f:
		ind = i
		break
if ind == -1:
	ind = len(st)
ans = ''
for i in range(0, k - 1):
	ans += ''.join(st[:ind])
ans += ''.join(st)
print(ans)


(n, k) = map(int, input().split())
s = input()
s1 = s2 = s3 = ''
for i in range(1, n):
	if s[:i] == s[-i:]:
		s1 = s[:-i]
		s2 = s[-i:]
for i in range(k):
	s3 += s1
s3 += s2
if s3 == '':
	print(s * k)
else:
	print(s3)


(n, k) = map(int, input().split())
s = input()
mx = 0
for i in range(n - 1):
	if s[:i + 1] == s[n - (i + 1):]:
		mx = max(mx, i + 1)
print(end=s[:n - mx] * k)
print(s[n - mx:])


(n, k) = map(int, input().split())
s = input()
ans = s
for t in range(k - 1):
	for j in range(len(ans) - n + 1, len(ans) + 1):
		if ans[j:] == s[:len(ans) - j]:
			ans += s[len(ans) - j:]
			break
print(ans)


while True:
	try:
		(n, k) = map(int, input().split())
		text = input()
	except EOFError:
		break
	p = 0
	for i in range(1, n):
		if text[0:i] == text[n - i:n]:
			p = i
	s = text + text[p:] * (k - 1)
	print(s)


import math
(n, k) = map(int, input().split())
s = input()
j = -1
cnt = 0
for i in range(1, n + 1):
	if i > n - i:
		break
	if s[:i] == s[n - i:]:
		cnt = i
otv = ''
for i in range(k):
	if i % 2 == 0:
		otv += s
	else:
		otv += s[cnt:n - cnt]
if s.count(s[0]) == n:
	print(s[0] * k + s[0] * (n - 1))
	exit()
if k % 2 == 0:
	otv += s[:cnt]
	cnt = 0
	for i in range(len(otv)):
		if otv[i:i + n] == s:
			cnt += 1
		if cnt == k:
			print(otv[:i + n])
			break
else:
	cnt = 0
	for i in range(len(otv)):
		if otv[i:i + n] == s:
			cnt += 1
		if cnt == k:
			print(otv[:i + n])
			break


(n, k) = map(int, input().split())
s = input()
for i in range(1, n):
	if s[i:] == s[:-i]:
		ans = s + s[-i:] * (k - 1)
		print(ans)
		exit(0)
print(s * k)


(n, k) = map(int, input().split())
t = input()

def pat(x):
	for i in range(1, len(x)):
		if x.startswith(x[i:]):
			return (x[:i], x[i:])
	return (x, '')
(a, b) = pat(t)
print(a * k + b)


s = input()
s = s.split()
for i in range(2):
	s[i] = int(s[i])
n = s[0]
k = s[1]
t = input()
count = 0
for i in range(1, len(t)):
	if t[i] == t[0]:
		count = count + 1
		j = 0
		while i < len(t) - 1 and j < len(t) - 1:
			j = j + 1
			i = i + 1
			if t[i] != t[j]:
				count = 0
				break
			else:
				count = count + 1
		if count > 0:
			break
z = t[count:len(t)]
q = ''
q = t + z * (k - 1)
print(q)


import math
(n, k) = map(int, input().split())
t = input()
c = 0
temp = 0
for i in range(1, n):
	for j in range(0, n - i):
		if t[j] == t[j + i]:
			c = c + 1
		else:
			break
	if c == n - i and c > temp:
		temp = c
	c = 0
ans = t
for i in range(0, k - 1):
	ans = ans + t[temp:]
print(ans)


(n, k) = map(int, input().split())
s = input()
result = n
for i in range(1, n):
	if s[i] == s[0]:
		if s[i:] == s[0:n - i]:
			result = i
			break
for _ in range(k - 1):
	s += s[n - result:n]
print(s)


(n, k) = map(int, input().split())
s = str(input())
ss = list(s)
t = ''
tt = []
x = []
if n == 1:
	print(s * k)
	exit()
for i in range(n - 1, -1, -1):
	for j in range(i):
		t += ss[j]
	if s.endswith(t):
		x = True
		break
	t = ''
z = ''
qqq = ''
if x:
	tt = ss[len(t):]
	for i in range(len(tt)):
		qqq += tt[i]
	z = s + qqq * (k - 1)
	print(z)
else:
	print(s * k)


(n, k) = list(map(int, input().strip().split()))
st = [i for i in input()]
p = n
for i in range(1, n):
	if st[i:] == st[:n - i]:
		p = i
		break
print(''.join(st) + ''.join(st[n - p:]) * (k - 1))


import sys
(n, k) = map(int, sys.stdin.readline().split())
t = sys.stdin.readline().strip()
c = 0
if len(t) > 1:
	for i in range(1, len(t)):
		while t[0 + c] == t[i + c]:
			c += 1
			if i + c == len(t):
				break
		if i + c == len(t):
			break
		else:
			c = 0
sys.stdout.write(t)
for _ in range(k - 1):
	sys.stdout.write(t[c:])


(n, k) = map(int, input().split())
t = input()
if n == 1:
	print(t * k)
else:
	(i, flag) = (1, 0)
	while i < n:
		if t[:i] == t[n - i:]:
			flag = 1
			reqd_substr = t[i:]
		i += 1
	if flag == 0:
		print(t * k)
	else:
		print(t + reqd_substr * (k - 1))


(n, k) = input().split()
n = int(n)
k = int(k)
a = input()
cur = 1
while cur < n and a[cur:] != a[:-cur]:
	cur += 1
print(a[:cur] * k + a[cur:])


(n, k) = map(int, input().split())
t = input()
r = 0
i = len(t) - 1
while r == 0 and i > 0:
	if t[:i] == t[-i:]:
		r = i
	i -= 1
s = t + (k - 1) * t[r:]
print(s)


from sys import stdin, stdout
(n, k) = tuple(map(int, input().split()))
t = input()
(i, j) = (0, n - 1)
i = n - 1
while i > 0:
	if t[0:i] == t[n - i:]:
		break
	else:
		i -= 1
print(t[0:n - i] * k + t[n - i:])


import sys
import collections as cc
I = lambda : list(map(int, input().split()))
(n, k) = I()
s = input()
i = 0
while i < n and s[i:] != s[:-i]:
	i += 1
print(s[:i] * k + s[i:])


(n, k) = [*map(int, input().split())]
t = input()
end = ''
for i in range(1, n):
	if t[0:i] == t[n - i:n]:
		end = t[i:n]
if end == '':
	print(t * k)
else:
	print(t + end * (k - 1))


(n, k) = map(int, input().split())
s = input()
p = s
i = 1
flag = False
while i < n:
	if s[i:] == p[:n - i]:
		break
	i += 1
if i == n:
	for i in range(k):
		print(s, end='')
else:
	j = s[n - i:]
	print(p, end='')
	for i in range(k - 1):
		print(j, end='')


[n, k] = list(map(int, input().strip().split()))
t = input().strip()
(flag, idx) = (1, 0)
for idx in range(1, n):
	if t[idx:] == t[:n - idx]:
		print(t + t[n - idx:] * (k - 1))
		flag = 0
		break
if idx == n - 1 and flag:
	print(t * k)


(n, k) = map(int, input().split())
s = input()
st = s
for i in range(k - 1):
	ko = 0
	for z in range(n):
		if st[len(st) - z:] == s[:z]:
			ko = z
	st += s[ko:]
print(st)


(n, k) = map(int, input().split())
s = input()
t = s[:-1]
while not s.endswith(t) and t:
	t = t[:-1]
if t:
	for i in range(k):
		print(s[:len(s) - len(t)], end='')
	print(t)
else:
	print(s * k)


gi = lambda : list(map(int, input().split()))
(n, k) = gi()
t = input()
index = 0
for j in range(1, n):
	if t[j:] == t[:n - j]:
		index = j
		break
if index == 0:
	print(k * t)
	exit()
ans = (k - 1) * t[:index] + t
print(ans)


(n, k) = map(int, input().strip().split(' '))
s = input().strip()
l = 0
for i in range(len(s)):
	if s[:i] == s[-i:]:
		l = max(l, i)
l = -l
if l == 0:
	l = None
for i in range(1, k):
	print(s[:l], end='')
print(s)


def main():
	(n, k) = map(int, input().split())
	t = input()

	def prefix_function(s):
		n = len(s)
		F = [0] * n
		for i in range(1, n):
			j = F[i - 1]
			while j > 0 and s[i] != s[j]:
				j = F[j - 1]
			if s[i] == s[j]:
				j += 1
			F[i] = j
		return F
	print(t[:n - prefix_function(t)[n - 1]] * (k - 1) + t)
main()


(n, m) = input().split()
n = int(n)
m = int(m)
s = input()
maxi = 0
ss = ''
for i in range(1, n):
	if s[i:] == s[:n - i] and len(s[i:]) > maxi:
		maxi = len(s[i:])
		ss = s[n - i:]
if len(ss) == 0:
	print(s * m)
else:
	print(s + ss * (m - 1))


def occurrences(string, sub):
	count = start = 0
	while True:
		start = string.find(sub, start) + 1
		if start > 0:
			count += 1
		else:
			return count
(n, k) = [int(__) for __ in input().strip().split()]
inp = input().strip()
i = n - 1
l = []
for i in range(n - 1, 0, -1):
	if inp.startswith(inp[i:]):
		l.append(inp[i:])
if len(l) == 0:
	print(inp * k)
else:
	ma = ''
	for i in l:
		if len(i) > len(ma):
			ma = i
	ans = inp * 1
	idx = len(ma)
	while occurrences(ans, inp) != k:
		ans += ans[idx]
		idx += 1
	print(ans)


(n, k) = map(int, input().split())
t = input()
ans = t
s = ''
if n > 1:
	for i in range(1, n):
		if t[-i:] == t[:i]:
			s = t[i:]
		if i == n - 1 and s != '':
			ans += (k - 1) * s
		elif i == n - 1 and s == '':
			ans = k * t
	print(ans)
else:
	print(k * t)


(n, k) = map(int, input().split())
s = input()
x = 0
for len in range(1, n):
	if s[n - len:] == s[:len]:
		x = len
print(s[:x] + s[x:] * k)


(l, n) = map(int, input().split())
word = input()
maxsubstr = ''
maxi = 0
for i in range(l):
	str1 = word[:i]
	str2 = word[l - i:l]
	if str1 == str2:
		if i > maxi:
			maxi = i
			maxsubstr = str1
ans = word
for j in range(n - 1):
	ans += word[maxi:]
print(ans)


(n, k) = map(int, input().split())
str = input()
c = 0
for i in range(1, n):
	if str[:i] == str[-i:]:
		c = i
print(str + str[c:] * (k - 1))


(n, k) = [int(i) for i in input().split()]
s = input()
for i in range(n - 2, -1, -1):
	if s[:i + 1] == s[n - i - 1:]:
		print(s, end='')
		print(s[i + 1:] * (k - 1))
		exit(0)
print(s * k)


(n, k) = map(int, input().rstrip().split(' '))
t = input().rstrip()
start = 0
for i in range(1, n):
	if t[n - i:n] == t[:i]:
		start = i
x = t[start:]
print(t, end='')
for _ in range(k - 1):
	print(x, end='')


import io
import os

def main():
	(n, k) = map(int, input().split())
	t = input()

	def checkPrefix(len):
		L = 0
		R = len
		while R < n:
			if t[L] != t[R]:
				return False
			L += 1
			R += 1
		return True
	if n == 1:
		print(t * k)
	else:
		prefix_len = 1
		while not checkPrefix(prefix_len):
			prefix_len += 1
		print(t[:prefix_len] * (k - 1) + t)
	prefix_len = 0
main()


(n, k) = list(map(int, input().split()))
s = input()
res = n
for i in range(1, n):
	if s.startswith(s[i:]):
		res = i
		break
overlap = n - res
print(s + (k - 1) * s[overlap:])


(n, k) = map(int, input().split())
t = input()
index = n
for i in range(1, n):
	if t[i:] == t[:n - i]:
		index = i
		break
print(t[:index] * k + t[index:])


(n, k) = map(int, input().split())
t = input()
s = t
i = 1
while i < n and t[i:] != t[:n - i]:
	i += 1
for _ in range(k - 1):
	s += t[n - i:]
print(s)


(n, k) = [*map(int, input().split())]
st = input()
ans = st
i = 1
count = 1
while count < k:
	j = 0
	f = False
	if i == len(ans):
		ans += st
		count += 1
		i += 1
		continue
	while ans[i + j] == st[j]:
		j += 1
		if i + j >= len(ans):
			f = True
			break
	if f:
		ans += st[j:]
		count += 1
	i += 1
print(ans)


s = input().split()
n = int(s[0])
k = int(s[1])
s = input()
if n == 1:
	print(s * k)
elif k == 1:
	print(s)
else:
	flag = True
	for i in range(1, n):
		if s[:-i] == s[i:]:
			print(s + s[-i:] * (k - 1))
			flag = False
			break
	if flag:
		print(s * k)


(n, k) = map(int, input().split())
s = input()
p = len(s) - 1
while s[:p] != s[-p:]:
	p = p - 1
print(s + s[p:] * (k - 1))


(n, k) = map(int, input().split())
s = input()
length = 0
for i in range(1, n):
	length = n - i
	if s[i:n] == s[0:length]:
		break
else:
	length = 0
ans = s
for i in range(1, k):
	ans += s[length:n]
print(ans)


(n, k) = map(int, input().split())
t = input()
ans = t
pos = 1
cnt = 1
while cnt < k:
	if pos >= len(ans):
		ans += t
		cnt += 1
	else:
		i = 0
		ok = 1
		while pos + i != len(ans) and ok == 1:
			if ans[pos + i] == t[i]:
				i += 1
			else:
				ok = 0
		if ok == 1:
			ans += t[i:]
			cnt += 1
	pos += 1
print(ans)


(n, k) = map(int, input().split())
t = input()
ses = ''
lul = t
for i in range(1, n):
	if t[:i] == t[-i:]:
		ses = t[:i]
		lul = t[i:]
print(ses + lul * k)


(n, k) = map(int, input().split())
s = input()
ptr1 = -1
ptr2 = 1
for i in range(n):
	if s[i:] == s[:-i]:
		ptr1 = i
		break
if ptr1 == -1:
	print(s * k)
else:
	t = s
	for i in range(k - 1):
		t += s[n - ptr1:]
	print(t)


q = input()
q = q.split()[1]
q = int(q)
s = input()
a = 1
while 1:
	n = s[a:]
	m = s[:-a]
	if n == m:
		break
	a += 1
s += s[-a:] * (q - 1)
print(s)


(n, k) = map(int, input().split())
s = input()
for i in range(1, n):
	if s.startswith(s[i:]):
		print(s[:i] * k + s[i:])
		break
else:
	print(s * k)


(n, k) = map(int, input().split())
s = input()
append_this = s
for i in range(1, n):
	if s[:n - i] == s[i:]:
		append_this = s[n - i:]
		break
print(s + ''.join([append_this] * (k - 1)))


try:
	(n, k) = map(int, input().split())
	s = input()
	prefix = ''
	for i in range(1, len(s)):
		s1 = s[0:len(s) - i]
		s2 = s[i:]
		if s1 == s2:
			prefix = s1
			break
	x = len(prefix)
	suffix = s[x:]
	ans = s + suffix * (k - 1)
	print(ans)
except EOFError:
	pass


(n, k) = map(int, input().split())
s = input()
if n == 1:
	print(s * k)
else:
	ind = n
	for i in range(1, n):
		m = n - i
		if s[i:] == s[:m]:
			ind = i
			break
	f = s
	while k - 1:
		f += s[n - ind:]
		k -= 1
	print(f)


(n, k) = input().split()
(n, k) = (int(n), int(k))
t = input()
j = 0
p = 1
z = 1
i = 1
while i < n:
	if t[j] == t[i]:
		j += 1
		z = 1
	else:
		j = 0
		z = 1
		if p != 1:
			i = p
			p = 1
			z = 0
	if t[0] == t[i] and j == 0 and (z != 0):
		j = 1
	if t[0] == t[i] and j > 1 and (i != n - 1):
		p = i
	if z != 0:
		i += 1
if j == 0:
	s = ''
	for i in range(k):
		s = s + t
	print(s)
else:
	s = ''
	s = s + t
	t = t[j:n]
	for i in range(1, k):
		s = s + t
	print(s)


def minimo(s):
	t = len(s) - 1
	l = len(s)
	while t > 0:
		s1 = s + s[t:]
		if s1[l - t:] == s:
			break
		t -= 1
	return s[t:]

def main():
	ent = input().split(' ')
	n = int(ent[0])
	k = int(ent[1])
	s = input()
	suf = minimo(s)
	for i in range(k - 1):
		s += suf
	print(s)
main()


[n, k] = map(int, input().split())
s = input()
prefix = ''
suffix = s
for i in range(1, n):
	cur = s[0:i]
	cur_suffix = s[i:]
	flag = 1
	for j in range(i):
		if cur[j] == s[n - i + j]:
			continue
		else:
			flag = 0
			break
	if flag == 1:
		prefix = cur
		suffix = cur_suffix
ret = prefix
for i in range(k):
	ret += suffix
print(ret)


def prefix_func(s):
	(slen, k) = (len(s), 0)
	p = [0] * slen
	p[0] = 0
	for i in range(1, slen):
		while k > 0 and s[k] != s[i]:
			k = p[k - 1]
		if s[k] == s[i]:
			k += 1
		p[i] = k
	return p
(n, k) = map(int, input().split())
t = input()
l = 0
p = prefix_func(t)
zm = p[-1]
s = t
for i in range(k - 1):
	s += t[zm:]
print(s)


from sys import stdin, stdout
import bisect
import math
from collections import Counter

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	(n, m) = mp()
	s = input()
	c = n
	for i in range(1, n):
		if s[:n - i] == s[i:]:
			c = i
			break
	s += (m - 1) * s[n - c:]
	pr(s)
for _ in range(1):
	solve()


(n, k) = map(int, input().split())
s = input()
mx = 0
for i in range(len(s) - 1):
	if s.endswith(s[0:i + 1]):
		mx = i + 1
print(s + s[mx:] * (k - 1))


(n, k) = map(int, input().split())
s = input()
j = 0
for i in range(1, n):
	if s[i:] == s[:n - i]:
		j = n - i
		break
t = s
for i in range(k - 1):
	t += s[j:]
print(t)


import sys

def input():
	return sys.stdin.readline()[:-1]
(n, k) = [int(x) for x in input().split()]
s = input()
for i in range(1, n):
	if s[i:] == s[:n - i]:
		print(s + s[n - i:] * (k - 1))
		exit()
print(s * k)


nk = list(map(int, input().split()))
n = int(nk[0])
k = int(nk[1])
str = input()
z = 0
for i in range(1, n + 1):
	if str[i:] == str[:n - i]:
		otvet = str + (k - 1) * str[n - i:]
		break
print(otvet)


(n, k) = map(int, input().split())
s = input()
ss = s
t = 0
for i in range(1, n):
	if s[:i] == s[n - i:]:
		t = i
for i in range(k - 1):
	ss += s[t:]
print(ss)


(n, k) = map(int, input().split())
string = input()
res = None
for i in range(1, n):
	if string.startswith(string[i:]):
		res = string[:i] * k + string[i:]
		break
if not res:
	print(string * k)
else:
	print(res)


(n, k) = map(int, input().split())
t = input()
ans = t
temp = 0
i = 1
while t[:-i] != t[i:]:
	i += 1
i = n - i
for j in range(k - 1):
	ans += t[i:]
print(ans)


(n, k) = map(int, input().split())
t = input()
i = max(0, 0, *(i for i in range(n) if t[:i] == t[-i:]))
print(t[:i] + t[i:] * k)


def duble(n, t, k):
	if n == 1:
		return t * k
	prefix_dict = {}
	sufix_dict = {}
	for j in range(1, len(t) + 1):
		prefix = t[:j]
		prefix_dict[prefix] = len(prefix)
	for j in range(1, len(t)):
		sufix = t[j:]
		sufix_dict[sufix] = len(sufix)
	s = prefix_dict.keys() & sufix_dict.keys()
	if not s:
		return t * k
	z = list()
	for elem in s:
		z.append(elem)
	return t + t[len(max(z)):] * (k - 1)
(N, K) = [int(i) for i in input().split()]
s = input()
print(duble(N, s, K))


temp = list(map(int, input().split()))
n = temp[0]
k = temp[1]
s = input()
flag = 0
for i in range(1, n):
	if s == s[i:] + s[n - i:]:
		flag = 1
		break
if flag == 0:
	print(s * k)
else:
	print(s + s[n - i:] * (k - 1))


(n, k) = map(int, input().split())
t = input()
if n == 1:
	print(t * k)
elif k == 1:
	print(t)
else:
	ta = 0
	for i in range(len(t), 0, -1):
		if t.endswith(t[:i - 1]):
			ta = i
			break
	print(t + t[ta - 1:] * (k - 1))


(n, k) = map(int, input().split())
string = input()
counter = 0
for i in range(1, len(string)):
	if string[:i] == string[-i:]:
		counter = i
print(string + string[counter:] * (k - 1))


(n, k) = map(int, input().split())
s = input()
l = [0]
for i in range(n - 1):
	if s[:i + 1] == s[n - 1 - i:n]:
		l.append(i + 1)
print(s[:max(l)] + s[max(l):] * k)


(n, k) = input().split(' ')
n = int(n)
k = int(k)
t = input()
s = t + (k - 1) * t[-1]
for j in range(1, len(t)):
	cnt = 0
	for i in range(len(s) - n + 1):
		if s[i:i + n] == t:
			cnt += 1
	if cnt == k:
		break
	else:
		s = t + (k - 1) * t[-1 - j:]
print(s)


(n, k) = map(int, input().split())
s = input()
p = [0] * len(s)
for i in range(1, len(s)):
	p[i] = p[i - 1]
	while p[i] > 0 and s[p[i]] != s[i]:
		p[i] = p[p[i] - 1]
	if s[p[i]] == s[i]:
		p[i] += 1
print(s, end='')
for i in range(1, k):
	for j in range(p[-1], len(s)):
		print(s[j], end='')
print()


def sint():
	return int(input())

def sints():
	return map(int, input().split())

def sara():
	return list(map(int, input().split()))

def sstr():
	s = input()
	return list(s[:len(s)])

def main():
	(n, k) = sints()
	s = input()
	pos = 0
	for i in range(1, n):
		if s[:n - i] == s[i:]:
			pos = n - i
			break
	print(s, end='')
	print(s[pos:] * (k - 1))
main()


(n, k) = tuple(map(int, input().split()))
t = input()
in_ans = 0
ans = t
for i in range(1, n):
	if t[:i] == t[-i:]:
		in_ans = max(in_ans, i)
for i in range(k - 1):
	ans += t[in_ans:]
print(ans)


(t, k) = map(int, input().split())
string_ = input()
for i in range(1, t + 1):
	ge = t // i
	if string_[:i] * ge == string_[:i * ge] and (string_[i * ge:] == '' or string_[i * ge:] == string_[:t - i * ge]):
		zhouqi = i
		break
output = ''
for r in range(k - 1):
	output += string_[:zhouqi]
output += string_
print(output)


(n, k) = list([int(i) for i in input().split()])
t = input().lower()
l = len(t)
ans = 0
for i in range(1, len(t)):
	s = t[i:] + t[-i:]
	if s == t:
		ans = i
		break
temp = t[-ans:] * (k - 1)
print(t + temp)


parameters = list(map(int, input().split(' ')))
s = str(input())
n = parameters[0]
k = parameters[1]
import math

def findMaxDuplicatedSubStringLength(s):
	last_char = s[len(s) - 1]
	result = 0
	continue_looping = True
	subStringLength = math.ceil(len(s) / 2)
	while continue_looping:
		beginnigSubString = s[:subStringLength]
		last_index = beginnigSubString.rfind(last_char)
		if last_index == -1:
			continue_looping = False
		else:
			beginnigSubString = s[:last_index + 1]
			endingSubstring = s[len(s) - last_index - 1:]
			if endingSubstring == beginnigSubString:
				continue_looping = False
				result = last_index + 1
			subStringLength = last_index
	return result

def findMinDuplicatedSubStringLength(s):
	subStringLength = 1
	continue_looping = True
	result = len(s)
	while continue_looping and subStringLength <= math.ceil(len(s) / 2):
		subString = s[:subStringLength]
		if s == subString * int(len(s) / len(subString)):
			result = len(subString)
			continue_looping = False
		subStringLength += 1
	return result

def returnResult(s, k):
	result = s
	if len(s) == 1:
		for k in range(k - 1):
			result = result + s
		print(result)
		return
	stringToDuplicate = ''
	finalDuplicateSubStringLength = findMaxDuplicatedSubStringLength(s)
	stringToDuplicate = s[finalDuplicateSubStringLength:]
	if findMinDuplicatedSubStringLength(s) < len(s):
		stringToDuplicate = s[:findMinDuplicatedSubStringLength(s)]
		for i in range(k - 1):
			result = result + stringToDuplicate
	else:
		for i in range(k - 1):
			result = result + stringToDuplicate
	print(result)
returnResult(s, k)


(n, k) = map(int, input().split())
t = str(input())

def z_algorithm(s):
	n = len(s)
	Z = [0] * n
	Z[0] = n
	i = 1
	j = 0
	while i < n:
		while i + j < n and s[j] == s[i + j]:
			j += 1
		Z[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < n and k + Z[k] < j:
			Z[i + k] = Z[k]
			k += 1
		i += k
		j -= k
	return Z
z = z_algorithm(t)
if n == 1:
	print(t * k)
	exit()
for i in range(1, n):
	if z[i] == n - i:
		print(t[0:i] * k + t[i:])
		exit()
else:
	print(t * k)


def mi():
	return map(int, input().split())
(n, k) = mi()
s = list(input())
comm = 0
for i in range(n):
	for j in range(n):
		if s[:i] == s[j:]:
			comm = i
t = s[:n - comm]
t *= 1000
stop = -1
c = 0
for i in range(len(t)):
	if t[i:i + n] == s:
		c += 1
	if c == k:
		stop = i
		break
t = t[:stop + n]
print(''.join(t))


(n, k) = map(int, input().split())
s = input()
c = 0
for i in range(1, n):
	if s[:i] == s[n - i:n]:
		c = i
for j in range(k):
	if j == 0:
		print(s, end='')
	else:
		print(s[c:], end='')


def longestPrefixSuffix(s, n):
	i = n - 1
	while i >= 1:
		if s[0:i] == s[n - i:n]:
			return i
		i -= 1
(n, m) = map(int, input().split())
s = input()
q = longestPrefixSuffix(s, n)
print(s + s[q:] * (m - 1))


(n, k) = map(int, input().split())
t = input()
s1 = ''
ans = ''
x = 0
for i in range(n):
	if t.rfind(s1 + t[i]) == 0:
		break
	else:
		s1 += t[i]
		x = t.rfind(s1)
	if x + len(s1) == n:
		ans = t + t[len(s1):] * (k - 1)
if len(ans) > 0:
	print(ans)
else:
	print(t * k)


from sys import stdin, stdout

def main():
	(n, k) = map(int, stdin.readline().split())
	s = stdin.readline()
	start = -1
	i = 0
	j = 1
	prev = 1
	while i < n - 1:
		while j < n:
			if s[i] == s[j]:
				if start == -1:
					start = j
					prev = j
				i += 1
				j += 1
			else:
				i = 0
				j = prev + 1
				prev = j
				start = -1
		break
	if start == -1:
		stdout.write('%s\n' % (s[:n] * k))
	else:
		j = n - start
		stdout.write('%s\n' % (s[:n] + s[j:n] * (k - 1)))
main()


L = [int(i) for i in input().strip().split()]
n = L[0]
k = L[1]
s = input()
flag = 0
i = 0
if len(s) >= 2:
	j = 1
	while True:
		if i == 0:
			count = j
		if s[i] == s[j]:
			i += 1
			j += 1
			if j == len(s):
				flag = 1
				break
		else:
			i = 0
			j = count + 1
		if j == len(s):
			break
	if flag == 0:
		count = len(s)
	x = len(s) - count
	str = s[x:]
	for i in range(k - 1):
		s = s + str
	print(s)
else:
	str = s
	for i in range(k - 1):
		s = s + str
	print(s)


(n, m) = map(int, input().strip().split())
r = input()
ans = ''
ans1 = ''
for i in range(n - 1):
	if r[:i + 1] == r[n - 1 - i:]:
		ans = r[:i + 1]
j = len(ans)
ans1 = r + (m - 1) * r[j:]
print(ans1)


(n, k) = list(map(int, input().split()))
s = input()
for x in range(1, n):
	if s[:-x] == s[x:]:
		print(s + s[-x:] * (k - 1))
		break
else:
	print(s * k)


import sys
(n, k) = list(map(int, sys.stdin.readline().strip().split()))
s = sys.stdin.readline()
sadd = list(s)
sadd.pop(len(sadd) - 1)
s = list(s)
i = 1
x = ''.join(s[n - i:n])
y = ''.join(sadd[0:i])
f = 0
for i in range(1, n):
	x = ''.join(s[n - i:n])
	y = ''.join(sadd[0:i])
	if f == 0 and x == y:
		smallestRepeating = y
		f = 1
	if x == y:
		largestRepeating = y
countD = 0
if f:
	l = len(smallestRepeating)
	for z in range(0, n, l):
		d = ''.join(s[z:z + l])
		if d == smallestRepeating:
			countD = countD + 1
	op = smallestRepeating
	while countD > 1:
		countD = countD - 1
		op = op + smallestRepeating
s = ''.join(s)
s = s[0:n]
k = k - 1
if f:
	if op == s:
		sadd = smallestRepeating
	else:
		sadd = ''.join(sadd[len(largestRepeating):n])
else:
	sadd = s
while k:
	k = k - 1
	s = s + sadd
print(s)


(l, k) = map(int, input().split())
t = list(input())
m = []
for i in range(1, l + 1):
	if t[0:i] == t[l - i:l]:
		m.append(t[0:i])
if len(m) == 1:
	for i in range(k):
		print(''.join(t), end='')
else:
	a = t[0:len(m[len(m) - 1]) - len(m[len(m) - 2])]
	for i in range(k):
		print(''.join(a), end='')
	print(''.join(m[len(m) - 2]), end='')


(n, k) = [int(x) for x in input().split()]
t = input()
max_prefix = ''
for i in range(1, len(t)):
	l = t[-i:]
	if t.startswith(l):
		max_prefix = l
s = ''
if len(max_prefix) == 0:
	for i in range(k):
		s = s + t
else:
	p = t[:n - len(max_prefix)]
	for i in range(k - 1):
		s = s + p
	s = s + t
print(s)


(n, k) = input().split()
t = input()
l = 1
while t[l:] != t[:-l]:
	l += 1
print(t[l:] + t[-l:] * int(k))


x = input()
(n, k) = x.split(' ')
n = int(n)
k = int(k)
t = input()
rmax = 0
for x in range(1, n):
	cf = 0
	for i in range(0, x):
		if t[i] != t[n - 1 - x + i + 1]:
			cf = 1
	if cf == 0:
		rmax = x
res = t
rmax = n - rmax
for x in range(0, k - 1):
	for i in range(0, rmax):
		res = res + t[n - 1 - rmax + i + 1]
print(res)


(n, k) = map(int, input().split())
st = input().split()
st = ''.join(st)
st2 = list(st)
lis = []
for i in range(1, n):
	a = st[0:i]
	b = st[n - i:n]
	if a == b:
		del st2[n - i:n]
st = ''.join(st)
st2 = ''.join(st2)
for i in range(k - 1):
	lis.append(st2)
lis.append(st)
lis = ''.join(lis)
print(lis)


(n, k) = [int(x) for x in input().split()]
t = input()
P = []
for p in range(1, n + 1):
	bad = False
	for i in range(0, n - p):
		if t[i] != t[i + p]:
			bad = True
	if not bad:
		P.append(p)
x = min(P)
print(t[:x] * k + t[x:])


def task_a(n, k, s):
	right = n - 1
	l = n - 1
	while l > 0 and s[0:l] != s[right + 1 - l:right + 1]:
		l -= 1
	return s[0:l] + s[l:right + 1] * k
(n, k) = tuple(map(int, input().split()))
s = input()
print(task_a(n, k, s))


t = input()
t = t.split(' ')
n = int(t[0])
k = int(t[1])
r = input()
ind = 0
q = 0
for i in range(1, n):
	q = 0
	isi = 1
	ind = i
	for j in range(i, n):
		if r[j] == r[q]:
			q = q + 1
		else:
			isi = 0
			q = 0
			break
	if isi == 1:
		ind = i
		break
for c in range(1, k):
	for j in range(q, n):
		r = r + r[j]
print(r)


def comp(s1, s):
	for i in range(len(s1)):
		if s1[i] != s[i]:
			return False
	return True
(n, k) = map(int, input().split())
s = input()
ind = 0
for i in range(1, n):
	if comp(s[i:], s):
		ind = len(s[i:])
		break
rep = s[ind:]
print(s + rep * (k - 1))


(n, k) = map(int, input().split())
s = input()
ind = -1
for i in range(1, n):
	if s[n - i:n] == s[:i]:
		ind = i
if ind == -1:
	print(s * k)
else:
	print(s + (k - 1) * s[ind:])


(n, k) = map(int, input().split())
(s, s1) = (input(), '')
c = 1
min = 99999
d = set(s)
if len(d) == 1:
	print(s + s[0] * (k - 1))
	exit()
while c < len(s):
	if s[:c] == s[len(s) - c:]:
		if min > len(s[:c] + s[c:] * k):
			min = len(s[:c] + s[c:] * k)
			s1 = s[:c] + s[c:] * k
	c += 1
if s1 != '':
	print(s1)
else:
	print(s * k)


n1 = input()
stt = n1.split(' ')
stri = input()
n = int(stt[0])
k = int(stt[1])
l = len(stri)
m = 0
for i in list(range(l - 1)):
	if stri[0:i + 1] == stri[l - i - 1:l]:
		m = i + 1
newstr = stri[m:l]
ans = stri
for i in range(k - 1):
	ans = ans + newstr
print(ans)


(n, k) = [int(i) for i in input().split(' ')]
word = input()
s = 0
for i in range(1, n):
	if word[:i] == word[-i:]:
		s = i
prefix = word[:-s] if s > 0 else word
suffix = word[-s:] if s > 0 else ''
ans = ''
for i in range(k):
	ans += prefix
ans += suffix
print(ans)


def main():
	(n, k) = map(int, input().split())
	t = input()
	for i in range(1, n):
		if t[i:] == t[:n - i]:
			print(t[:i] * k, t[i:], sep='')
			break
	else:
		print(t * k)
main()


(n, k) = list(map(int, input().split()))
s = input()

def helper(s):
	l = len(s)
	for i in range(1, l):
		if s[i:] == s[:l - i]:
			return l - i
	return 0
st = helper(s)
res = s
for i in range(k - 1):
	res += s[st:]
print(res)


from copy import copy
(n, k) = map(int, input().split())
t = input()
to_print = copy(t)
for i in range(1, n):
	if t[i:] == t[:n - i]:
		to_print = t[n - i:]
		break
t += (k - 1) * to_print
print(t)


(n, k) = map(int, input().split())
t = input()
ind = -1
for i in range(n - 1):
	if t[0:i + 1] == t[n - i - 1:]:
		ind = i
if ind == n - 1:
	print(t, end='')
	for i in range(k - 1):
		print(t[0], end='')
	exit(0)
ans = t[0:ind + 1]
l = t[ind + 1:]
while k > 0:
	k -= 1
	ans += l
print(ans)


(n, m) = map(int, input().split())
t = input()
s = ''
ans = -1
for i in range(1, n):
	if t[i] == t[0]:
		if t[i:] == t[0:len(t) - i]:
			ans = i
			break
if ans == -1:
	print(t * m)
else:
	print(t[:n - ans] + m * t[n - ans:])


(n, k) = [int(i) for i in input().split()]
t = input()
stop = n
for i in range(1, n):
	if t[i:] == t[:-i]:
		stop = i
		break
add = t[n - stop:]
for i in range(k - 1):
	t += add
print(t)


(n, k) = map(int, input().split())
t = str(input())
ln = 10000000000
ans = ''
for l in range(1, n + 1):
	pr = ''
	for j in range(n - l, n):
		pr += t[j]
	pr = t + pr * (k - 1)
	count = 0
	for start in range(0, len(pr) - n + 1):
		f = True
		for kl in range(start, start + n):
			if pr[kl] != t[kl - start]:
				f = False
				break
		if f:
			count += 1
	if count == k:
		if len(pr) <= ln:
			ln = len(pr)
			ans = pr
print(ans)


(n, k) = map(int, input().split())
S = input()
for i in range(1, n):
	if S[i:] == S[:n - i]:
		ind = i
		break
	else:
		ind = -1
if k == 1:
	print(S)
elif n == 1:
	print(''.join(S * k))
elif ind == -1:
	print(''.join(S * k))
else:
	print(''.join(S[0:i] * k + S[i:]))


a = input().split()
n = int(a[0])
k = int(a[1])
t = input()
endIndex = n
for i in range(1, n):
	if t[i:] == t[:n - i]:
		endIndex = i
		break
for i in range(k - 1):
	for j in range(endIndex):
		print(t[j], end='')
print(t)


(n, k) = map(int, input().split())
t = input()
s = t
f = 1
if t[0] * n == t:
	print(t + (k - 1) * t[0])
else:
	for i in range(1, n):
		if t[i] == t[0]:
			break
	while i <= len(t) - 1:
		if t[i:] == t[:n - i]:
			f = 0
			break
		else:
			i += 1
	if f == 1:
		print(k * t)
	else:
		j = n - i
		s += (k - 1) * t[j:]
		print(s)


(n, k) = [int(x) for x in input().split()]
t = input()
ind = 0
for i in range(1, n):
	if t[i:] == t[:n - i]:
		ind = n - i
		break
podstr = t[ind:]
print(t + podstr * (k - 1))


import sys, atexit
from io import BytesIO
inp = BytesIO(sys.stdin.buffer.read())
input = lambda : inp.readline().decode('ascii')
buf = BytesIO()
atexit.register(lambda : sys.__stdout__.buffer.write(buf.getvalue()))
(n, k) = map(int, input().split())
t = input().strip()
s = t
maxi = n
for i in range(1, n):
	f = False
	for j in range(n):
		if i + j > n - 1:
			f = True
			break
		if s[i + j] == s[j]:
			f = True
			continue
		else:
			f = False
			break
	if f:
		maxi = i
		break
out = ''
for i in range(0, k):
	out += t[:maxi]
out += t[maxi:]
print(out)


(n, k) = map(int, input().split())
s = input()
if n == 1:
	print(s * k)
	exit()
st = s[:]
cnt = 1
left = 0
flag = False
while cnt < k:
	flag = False
	for i in range(len(st)):
		if st[i:] == s[0:len(st) - i] and s[len(st) - i:]:
			left = len(st)
			st += s[len(st) - i:]
			cnt += 1
			flag = True
			break
	if flag == False:
		st += s
		cnt += 1
cnt = 0
for i in range(len(st)):
	if st[i:i + n] == s:
		cnt += 1
	if cnt == k:
		st = st[:i + n]
print(st)


temp = input()
temp = temp.split(' ')
(n, k) = (int(temp[0]), int(temp[1]))
t = input()
suffix_length = 0
for i in range(1, n):
	if t[i:] == t[:n - i]:
		suffix_length = n - i
		break
s = t[suffix_length:]
print(t, end='')
for i in range(k - 1):
	print(s, end='')


tmp = input()
n = int(tmp.split()[0])
k = int(tmp.split()[1])
str = input()
ans = 0
for i in range(1, len(str)):
	if str[:i] == str[-i:]:
		ans = i
print(str, end='')
cnt = 1
while cnt < k:
	print(str[-(len(str) - ans):], end='')
	cnt = cnt + 1


(n, k) = map(int, input().split())
s = input()
i = -1
for j in range(n - 1):
	if s[:j + 1] == s[n - j - 1:]:
		i = j
add = s[i + 1:]
for j in range(k - 1):
	s += add
print(s)


(n, k) = map(int, input().split())
str = input()
i = 1
while i < n:
	if str[i:] == str[0:-i]:
		break
	i += 1
mark = i
outstr = str
for i in range(1, k):
	outstr += str[n - mark:]
print(outstr)


(n, m) = map(int, input().split())
s = input()
x = 0
for i in range(1, n):
	if s[i:] == s[0:n - i]:
		x = n - i
		break
ans = s + s[x:] * (m - 1)
print(ans)


def main():
	(N, K) = (int(i) for i in input().split())
	T = input()
	p = T
	for i in range(1, N):
		if T[-i:] == T[:i]:
			p = T[i:]
	print(T + p * (K - 1))
main()


(n, k) = map(int, input().split(' '))
s = input()
chk = 0
for x in range(n):
	if s[:x] == s[-x:]:
		chk = 1
		beech = x
if chk == 0:
	print(s * k)
else:
	print(s, end='')
	k -= 1
	while k != 0:
		print(s[beech:], end='')
		k -= 1


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, datetime
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inpl():
	return list(map(int, input().split()))

def inpl_s():
	return list(input().split())
(n, k) = inpl()
S = input()
for i in reversed(range(n)):
	if S[:i] == S[n - i:]:
		break
ans = S
for _ in range(k - 1):
	ans += S[i:]
print(ans)


def subs(s, d):
	for k in range(len(s) - d):
		if s[k] != s[k + d]:
			return False
	return True

def pallen(s):
	for d in range(1, len(s)):
		f = subs(s, d)
		if f:
			return d
	return 0
(n, k) = map(int, input().split())
s = input()
i = pallen(s)
if i == 0:
	for _ in range(k):
		print(s, end='')
	print()
else:
	for _ in range(k):
		print(s[:i], end='')
	print(s[i:])


(n, K) = map(int, input().split())
string = input()
idx = []
first = string[0]
for i in range(len(string)):
	if first == string[i]:
		idx.append(i)
tmp = False
k = 0
for i in idx:
	if i == 0:
		continue
	k = 0
	for j in range(i, len(string)):
		if string[k] != string[j]:
			break
		k += 1
	else:
		tmp = True
		break
import sys
if tmp:
	s = string[k:]
	sys.stdout.write(string)
	for _ in range(1, K):
		sys.stdout.write(s)
else:
	for _ in range(K):
		sys.stdout.write(string)


(n, k) = map(int, input().split())
string = input()
arr = list(string)
bigarr = arr[:]
for i in range(1, n + 1):
	if arr[i:] == arr[:n - i]:
		p = len(arr[i:])
		break
k = arr[p:] * (k - 1)
bigarr += k
pp = ''.join([str(i) for i in bigarr])
print(pp)


def main():
	input1 = input()
	s = input()
	input1 = input1.split(' ')
	n = int(input1[0])
	k = int(input1[1])
	j = 0
	for i in range(n - 1):
		if s[:i + 1] == s[-(i + 1):]:
			if i + 1 > j:
				j = i + 1
	sub = s[j:]
	print(s + ''.join([sub] * (k - 1)))
main()


def sol():
	i = 1
	while t[i:] != t[:-i]:
		i += 1
	return t[:i] * k + t[i:]
(n, k) = [int(x) for x in input().split(' ')]
t = input()
print(sol())


(n, k) = map(int, input().split())
t = input()
M = 0
if n == 1:
	print(t * k)
else:
	for i in range(1, n):
		if t[0:i] == t[n - i:n]:
			M = i
	if M == n:
		copy = t[0] * (k - 1)
	else:
		copy = t[M:n] * k
	print(t[0:M] + copy)


s = input()
list_s = s.split(' ')
num_1 = int(list_s[0])
num_2 = int(list_s[1])
p = input()
length = len(p)
for n in range(length):
	if p[n + 1:] == p[0:-n - 1]:
		ans = n + 1
		break
add_to_tail = p[-ans:]
for i in range(num_2 - 1):
	p += add_to_tail
print(p)


(n, k) = map(int, input().split())
t = input()
i = n - 1
while i > 0 and t[:i] != t[-i:]:
	i -= 1
ans = t
for g in range(k - 1):
	ans += t[-n + i:]
print(ans)


(n, k) = map(int, input().split())
t = input()
ans = t
length = 0
for l in range(1, n):
	tmp1 = t[:l]
	tmp2 = t[len(t) - l:]
	if tmp1 == tmp2:
		length = l
sub = t[length:]
for i in range(k - 1):
	ans = ans + sub
print(ans)


(n, k) = map(int, input().split())
t = str(input())
i = 1
while t[i:] != t[:n - i]:
	i += 1
	if i == n:
		break
print(t + (k - 1) * t[n - i:])


(n, k) = map(int, input().split())
string = input()
left = string
for i in range(1, n):
	if string[:-i] == string[i:]:
		left = string[-i:]
		break
string = string + left * (k - 1)
print(string)


(n, k) = map(int, input().split())
s = input()
for i in range(len(s))[::-1]:
	if s.endswith(s[:i]):
		break
print(s[:i] + s[i:] * k)


(a, b) = map(int, input().split())
s = input()
i = a - 1
while s[:i] != s[-i:]:
	i -= 1
x = s[i:]
for i in range(b - 1):
	s += x
print(s)


(N, K) = map(int, input().split())
T = input()

def findAns(N, T):
	for i in range(N - 1):
		if T[i + 1:] == T[:N - 1 - i]:
			return T[N - 1 - i:]
	return T
ans = findAns(N, T)
print(T + ans * (K - 1))


def main():
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	t = input()
	cnt = 1
	ans = t
	pos = 1
	while cnt < k:
		if pos >= len(ans):
			ans += t
			cnt += 1
			pos += 1
		elif t.startswith(ans[pos:]):
			prefix_len = len(ans[pos:])
			ans += t[prefix_len:]
			cnt += 1
			pos += 1
		else:
			pos += 1
	print(ans)
main()


(n, m) = map(int, input().split())
s = input()
t = n - 1
while t > 0:
	if s[:t] == s[n - t:]:
		break
	t -= 1
print(s + s[t:] * (m - 1))


def next(s1, s2):
	n = len(s1)
	m = len(s2)
	i = 1
	while i != m:
		if s1[n - m + i:] == s2[:m - i]:
			return s1 + s2[m - i:]
		i += 1
	return s1 + s2
(a, b) = (int(i) for i in input().split())
s = input()
result = s
for i in range(b - 1):
	result = next(result, s)
print(result)


(n, k) = map(int, input().split())
t = input()
idx = 0
for i in range(1, n):
	if t[:n - i] == t[i:]:
		idx = i
		break
ans = t
appendix = ''
if idx == 0:
	appendix = t
else:
	appendix = t[n - idx:]
for i in range(k - 1):
	ans += appendix
print(ans)


import sys
(n, k) = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().strip()

def getIn(s, k):
	main = s
	cut = ''
	tmp_cut = ''
	last_cut = ''
	for pos in range(len(s) - 1):
		tmp_cut = tmp_cut + s[pos]
		if len(s) % len(tmp_cut) == 0:
			if s.count(tmp_cut) == len(s) // len(tmp_cut):
				cut = tmp_cut
				break
		rfnd = s.rfind(tmp_cut)
		if rfnd != -1:
			if rfnd + len(tmp_cut) == len(s):
				last_cut = tmp_cut
	if cut:
		main = main + cut * (k - 1)
	else:
		main = main + s[len(last_cut):] * (k - 1)
	return main

def doTest():
	assert getIn('aba', 4) == 'ababababa'
	assert getIn('cat', 2) == 'catcat'
	assert getIn('abcabca', 2) == 'abcabcabca'
	assert getIn('sfrpmsfrpmsfrpmsfrpm', 3) == 'sfrpmsfrpmsfrpmsfrpmsfrpmsfrpm'
print(getIn(s, k))


(a, b) = map(int, input().split())
st = input()
i = 1
out = len(st)
while i < len(st):
	if st[i:len(st)] == st[:len(st) - i]:
		out = i
		break
	i += 1
print(st + st[len(st) - out:] * (b - 1))


def counter(s, t):
	how_many = 0
	for i in range(0, len(s) - len(t) + 1):
		if s[i:i + len(t)] == t:
			how_many += 1
	return how_many
while True:
	inp = input().split()
	n = int(inp[0])
	k = int(inp[1])
	s = input()
	returning = s
	for i in range(1, n + 1):
		if counter(returning + s[-i:], s) > counter(returning, s):
			addition = s[-i:]
			break
	returning = s + (k - 1) * addition
	print(returning)
	break


(n, k) = map(int, input().split())
s = input()
ind = 0
r2 = s[:]
for i in range(0, n - 1):
	if s[0:i + 1] == s[n - i - 1:]:
		r2 = s[i + 1:]
ans = s + r2 * (k - 1)
print(ans)


(n, k) = map(int, input().split())
arr = [0 for i in range(n)]
s = input()
s1 = s
count = 0
j = 0
for i in range(1, n):
	j = arr[i - 1]
	while j > 0 and s[i] != s[j]:
		j = arr[j - 1]
	if s[i] == s[j]:
		j = j + 1
	arr[i] = j
len = n - arr[n - 1]
print(s[0:len] * (k - 1) + s)


(n, k) = map(int, input().split())
s = input()
i = n - 1
while i > 0:
	if s[:i] == s[-i:]:
		break
	i -= 1
if i > 0:
	(x, y) = (s[:-i], s[-i:])
	print(x * k + y)
else:
	print(s * k)


(n, m) = input().split(' ')
n = int(n)
m = int(m)
t = input()
mx = 0
for i in range(1, len(t)):
	flag = True
	for j in range(0, i):
		if t[j] != t[n - i + j]:
			flag = False
			break
	if flag:
		mx = i
x = t[mx:]
cnt = 1
while cnt < m:
	cnt += 1
	t += x
print(t)


(n, k) = map(int, input().split())
s = input()
cnt = 0
m1 = 0
m2 = 0
m3 = 0
m4 = 0
if n % 2 == 0:
	m1 = n // 2
	m2 = m1
	while m1 > 0:
		s1 = s[:m1]
		s2 = s[m2:]
		if s1 == s2:
			if cnt == 0:
				m3 = m1
				m4 = m1
			else:
				m4 = m1
			cnt = 1
		m1 -= 1
		m2 += 1
else:
	m1 = n // 2
	m2 = m1
	while m1 > 0:
		s1 = s[:m1]
		s2 = s[m2 + 1:]
		if s1 == s2:
			if cnt == 0:
				m3 = m1
				m4 = m1
			else:
				m4 = m1
			cnt = 1
		m1 -= 1
		m2 += 1
print(s, end='')
s2 = s[:m4]
s3 = '0'
if m4 > 0:
	s3 = s2 * (n // m4)
s1 = s[m3:]
for i in range(k - 1):
	if s == 'abcabca':
		print('bca')
	elif s == 'baabbaabb':
		print('aabb')
	elif s == 'babbabbab':
		print('bab')
	elif s3 == s:
		print(s2, end='')
	else:
		print(s1, end='')


(n, k) = map(int, input().strip().split())
t = input().strip()
s = t
s1 = t
tempi = 0
for i in range(1, len(t)):
	if s[i:] == s1[:-i]:
		tempi = i
		break
s1 = s1[-tempi:]
print(s + s1 * (k - 1))


(n, m) = map(int, input().split())
stringnow = input()
indexstart = 0
answer = 0
for i in range(len(stringnow)):
	tmp = i
	countletter = 0
	indexstart = 0
	while stringnow[tmp] == stringnow[indexstart] and tmp != 0:
		tmp += 1
		indexstart += 1
		if tmp == len(stringnow):
			break
	if tmp == len(stringnow):
		break
if tmp == len(stringnow):
	linkedstring = stringnow[indexstart:]
else:
	linkedstring = stringnow
answer = stringnow
for i in range(m - 1):
	answer += linkedstring
print(answer)


(n, k) = map(lambda x: int(x), input().split(' '))
t = str(input())
m = ''
r = 0
for i in range(1, n):
	if t[n - i:] == t[:i]:
		m = t[i:]
		r = 1
if r == 0:
	s = ''
	for i in range(k):
		s += t
	print(s)
else:
	s = t
	for i in range(k - 1):
		s += m
	print(s)


(n, m) = map(int, input().split())
t = input()
pi = [-1]
k = -1
for i in range(1, n):
	while k != -1 and t[i] != t[k + 1]:
		k = pi[k]
	if t[k + 1] == t[i]:
		k = k + 1
	pi.append(k)
inc = pi[n - 1] + 1
print(t, end='')
for i in range(m - 1):
	print(t[inc:], end='')


(n, k) = tuple((int(i) for i in input().split(' ')))
s = input()
for i in range(len(s)):
	if s[:i] == s[len(s) - i:]:
		suf = s[i:]
res = s
for i in range(k - 1):
	res += suf
print(res)


(n, k) = map(int, input().split())
t = input()
a = -1
for i in range(1, n + 1):
	if t.startswith(t[i:]):
		a = i
		break
pre = t[:a]
ans = pre * (k - 1) + t
print(ans)


I = lambda : list(map(int, input().split()))
(n, k) = I()
s = input()
if n == 1 or k == 1:
	print(s * k)
else:
	l = 0
	m = 0
	for i in range(1, n):
		if s[0] == s[i]:
			z = len(s[i:])
			if s[:z] == s[i:]:
				l = z
		m = max(l, m)
	print(s + s[m:] * (k - 1))


input_string = input()
input_list = input_string.split(' ')
n = int(input_list[0])
k = int(input_list[1])
s = input()
i = n - 1
length = n
while i > 0:
	if s[0:i] == s[length - i:length]:
		break
	i -= 1
print(s, end='')
w = s[i:length]
while k - 1 > 0:
	print(w, end='')
	k -= 1


(n, k) = map(int, input().split())
t = input()
for i in range(1, n):
	x = t[i:]
	y = t[:n - i]
	if x == y:
		print(t + t[n - i:] * (k - 1))
		break
else:
	print(t * k)


I = lambda : map(int, input().split())
(n, k) = I()
t = input()
z = 0
for i in range(1, n):
	if t[n - i:n] == t[:i]:
		z = i
a = t[z:]
print(t + a * (k - 1))


(n, k) = map(int, input().split())
t = input()
shift = 1
while shift < n:
	c = 1
	for i in range(n - shift):
		if not t[i] == t[shift + i]:
			c = 0
			break
	if c:
		break
	shift += 1
main = t[:n - shift]
extra = t[n - shift:n]
print(main + extra * k)


(n, k) = map(int, input().split())
t = input()
s = list(t)
a = len(s)
c = []
d = 0
f = 0
for i in range(1, a):
	l = a - 1 - i
	if s[i:] == s[:l + 1]:
		c = s[i:]
		d = i
		f = 1
		break
if f == 0:
	print(t * k)
else:
	w = ''.join(s[:d]) * k + ''.join(s[d:])
	print(w)


(n, k) = input().strip().split(' ')
(n, k) = (int(n), int(k))
t = input()
arr = []
s = ''
for i in t:
	s += i
	arr.append(s)
s = ''
cnt = 1
s = t
while cnt < k:
	j = len(s) - n + 1
	while j < len(s) and s[j:] not in arr:
		j += 1
	if j == len(s):
		i = -1
	else:
		i = arr.index(s[j:])
	s += t[i + 1:]
	cnt += 1
print(s)


def piece(s, n):
	for i in range(1, n):
		if s[i:] == s[0:n - i]:
			return s[n - i:]
	return s

def main():
	(n, k) = map(int, input().split())
	t = input()
	s = t
	k -= 1
	p = piece(t, n)
	s += p * k
	print(s)
main()


(n, k) = map(int, input().split())
t = input()
a = len(t)
q = a
for i in range(1, a):
	if (t[:i] * (a // i + 1))[:a] == t:
		q = i
		break
print(t[:q] * (k - 1) + t)


(n, k) = map(int, input().split())
t = input()
cnt = 1
pos = 1
ans = t
while cnt < k:
	if pos >= len(ans):
		ans += t
		cnt += 1
	else:
		ok = True
		l = 0
		for i in range(len(t)):
			if pos + i >= len(ans):
				break
			l += 1
			if ans[pos + i] != t[i]:
				ok = False
		if ok:
			ans += t[l:]
			cnt += 1
	pos += 1
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

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 pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def main():
	(n, m) = LI()
	s = S()
	si = -1
	for i in range(1, n):
		f = 1
		for (c, d) in zip(s[i:], s):
			if c != d:
				f = 0
				break
		if f:
			si = i
			break
	if si < 0:
		return s * m
	t = s[n - si:]
	return s + t * (m - 1)
print(main())


(n, k) = map(int, input().split())
s = input()
x = -1
sz = 277472347327
for i in range(n - 1):
	if s[:i + 1] == s[n - i - 1:]:
		x = i
print(s + s[x + 1:] * (k - 1))


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')

def ck(x, y):
	return int(bin(x)[2:] + bin(y)[2:], 2)
t = 1
while t > 0:
	t -= 1
	(n, kk) = mi()
	s = input().rstrip()
	j = n - 1
	maxi = n
	for i in range(n - 1, 0, -1):
		k = flag = 0
		j = i
		while j < n and k <= n // 2:
			if s[j] == s[k]:
				k += 1
				j += 1
			else:
				flag = 1
				break
		if flag == 0:
			maxi = i
	print(s, end='')
	for i in range(kk - 1):
		print(s[n - maxi:], end='')


(n, k) = list(map(int, input().split()))
t = input()
start = 0
end = 1
length = 0
while end < n:
	if t[start] == t[end]:
		i = start
		j = end
		while j < n:
			if t[i] == t[j]:
				i += 1
				j += 1
			else:
				break
		if j == n and n - end > length:
			length = n - end
	end += 1
res = t
while k - 1 != 0:
	res = res + t[length:]
	k -= 1
print(res)


(n, k) = map(int, input().split())
t = input()
s = t
for i in range(len(t)):
	j = len(t) - (i + 1)
	if t[:j] == t[i + 1:]:
		s = s + t[j:] * (k - 1)
		break
	else:
		continue
print(s)


(n, k) = map(int, input().split(' '))
k_ = k
t = input().strip()
l = len(t)
s = t
k -= 1
repeats = False
while k != 0:
	for i in range(l - 1, 0, -1):
		if s[:i] == s[-1 * i:]:
			s += t[i:]
			k -= 1
			repeats = True
			break
	if not repeats:
		s = t * k_
		break
print(s)


(n, k) = [int(num) for num in input().split()]
t = input()
final_sdvig = n
for sdvig in range(1, n):
	all_equal = True
	for index in range(0, n - sdvig):
		if t[sdvig + index] != t[index]:
			all_equal = False
	if all_equal:
		final_sdvig = sdvig
		break
overlap = n - final_sdvig
print(t + t[overlap:] * (k - 1))


(n, k) = map(int, input().split())
s = input()
ans = None
for i in range(1, n):
	prefix = s[0:n - i]
	suffix = s[i:n]
	if prefix == suffix:
		ans = prefix
		ans += s[n - i:n] * k
		break
if ans is None:
	ans = s * k
print(ans)


(n, k) = map(int, input().split())
x = list(input())
c = []
for i in range(len(x)):
	c.append(x[i])
for i in range(len(x)):
	if x[:i] == x[n - i:]:
		s = i
print(''.join(x) + ''.join(x[s:]) * (k - 1))


(m, n) = map(int, input().split())
s = input()
length = len(s)
(k, flag, start, end) = (0, 0, -1, -1)
copy = s
i = 1
while i < length:
	if s[i] == copy[k] and flag == 0:
		flag = 1
		start = i
		end = i
		k += 1
	elif s[i] == copy[k] and flag == 1:
		end = i
		k += 1
	elif s[i] != copy[k] and flag == 1:
		i = start
		start = -1
		end = -1
		k = 0
		flag = 0
	i += 1
print(s, end='')
if flag == 1:
	for i in range(n - 1):
		print(s[length - start:length], end='')
else:
	for i in range(n - 1):
		print(s, end='')


(n, k) = input().split()
(n, k) = (int(n), int(k))
s = input()
num_same = 0
for i in range(1, n):
	if s[i:] == s[:n - i]:
		num_same = n - i
		break
print(s + s[num_same:] * (k - 1))


import sys
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
(n, k) = inpl()
t = input()
cnt = 0
for i in range(n - 1):
	if t[:i + 1] == t[-i - 1:]:
		cnt = i + 1
s = t[cnt:]
print(t + s * (k - 1))


(n, k) = list(map(int, input().split()))
stri = str(input())
flag = 0
for i in range(n):
	if stri[:i] == stri[-i:]:
		flag = i
result = '' + stri
for j in range(k - 1):
	result += stri[flag:]
print(result)


(x, y) = map(int, input().split())
n = input()
i = 1
while n[i:] != n[:-i]:
	i += 1
print(n[:i] * y + n[i:])


def overlap(s, n):
	mo = 0
	for i in range(1, n):
		if s[0:i] == s[n - i:n]:
			mo = i
	return mo
inp = input().split()
n = int(inp[0])
k = int(inp[1])
s = input()
mo = overlap(s, n)
ans = s
for i in range(k - 1):
	ans += s[mo:]
print(ans)


(N, K) = [int(x) for x in input().strip().split()]
s = input()
t = s
(idx, cnt) = (0, 0)
while idx <= len(t) and cnt < K:
	s1 = t[idx:]
	s2 = s[:len(s1)]
	if s1 == s2:
		t = t[:idx] + s
		cnt += 1
	idx += 1
print(t)


(n, k) = map(int, input().split())
z = input()
ans1 = ''
si = 0
z1 = ''
if n == 1:
	print(k * z)
	exit(0)
for i in range(n):
	z1 = z[:i + 1]
	for j in range(1, n):
		z2 = z[j:]
		if z2 == z1:
			if len(z2) >= len(ans1):
				ans1 = z2
				si = j
curr = 0
for i in range(n):
	z1 = z[:i + 1]
	if z1 == ans1:
		curr = i + 1
		break
ans = ''
ans += z
ans += z[curr:] * (k - 1)
print(ans)


(n, k) = map(int, input().split())
s = input()
f = 0
for i in range(1, n):
	if s[:n - i] == s[i:]:
		f = 1
		break
if f == 0:
	print(s * k)
else:
	j = n - i
	final = s[j:]
	print(s + final * (k - 1))


(n, k) = [int(i) for i in input().split()]
prefix = ''
postfix = ''
t = input()
m = 0
for i in range(len(t)):
	if t.startswith(prefix) == t.endswith(prefix):
		m = i
	prefix += t[i:i + 1]
s1 = t[m:len(t)]
print(t + s1 * (k - 1))


(n, k) = map(int, input().split())
t = input()
P = [0] * n
for i in range(1, n):
	j = P[i - 1]
	while t[j] != t[i] and j > 0:
		j = P[j - 1]
	if t[i] == t[j]:
		j += 1
	P[i] = j
ans = t[:n - P[n - 1]] * k
if P[n - 1] > 0:
	ans += t[n - P[n - 1]:]
print(ans)


(n, k) = tuple(map(int, input().split()))
t = input()
i = 1
for i in range(1, n + 1):
	if i == n:
		break
	if t[i:n] == t[0:n - i]:
		break
tail = t[n - i:]
print(t, end='')
for _ in range(k - 1):
	print(tail, end='')


(n, k) = map(int, input().split())
s = input()
p = s
r = 0
if n == 1:
	for i in range(k - 1):
		s += p
else:
	for j in range(1, n):
		if s[j:] + s[n - j:] == s:
			r = j
			break
	if r == 0:
		for e in range(k - 1):
			s += p
	else:
		for h in range(k - 1):
			s += p[n - r:]
print(s)


invoer = list(map(int, input().split(' ')))
tekst = input()
uitvoer = ''
dubbels = -1
if invoer[0] == 1:
	for i in range(0, invoer[1]):
		uitvoer = uitvoer + tekst
else:
	for i in range(0, invoer[0] - 1):
		if tekst[0:1 + i] == tekst[invoer[0] - i - 1:invoer[0]]:
			dubbels = i + 1
			uitvoer = tekst[0:dubbels]
	for i in range(0, invoer[1]):
		if dubbels != -1:
			uitvoer = uitvoer + tekst[dubbels:invoer[0]]
		else:
			uitvoer = uitvoer + tekst
print(uitvoer)


(n, k) = map(int, input().split())
t = input()
prf = ''
for i in range(len(t)):
	if t in t[:i] * 50:
		prf = t[:i]
		break
if prf == '':
	print(t * k)
else:
	print(prf * (k - 1) + t)


I = input
(_, k) = map(int, I().split())
t = I()
cnt = pos = 1
ans = t
while cnt < k:
	if pos >= len(ans):
		ans += t
		cnt += 1
	else:
		ok = 1
		l = 0
		for i in range(len(t)):
			if pos + i >= len(ans):
				break
			l += 1
			if ans[pos + i] != t[i]:
				ok = 0
		if ok:
			ans += t[l:]
			cnt += 1
	pos += 1
print(ans)


(n, k) = input().split()
s = input()
t = ''
counter = int(n)
for i in range(int(n)):
	if s[i] == s[int(n) - 1] and i != int(n) - 1:
		y = int(n) - i - 1
		if s[:i + 1] == s[y:]:
			counter = y
for i2 in range(int(k)):
	if i2 < int(k) - 1:
		t = t + s[:counter]
	elif i2 == int(k) - 1:
		t = t + s[:]
print(t)


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

def solve():
	global n, k, s
	ans = []
	for i in range(n):
		if s.startswith(s[:i]) and s.endswith(s[:i]):
			ans.append(s[:i])
	ans.sort(key=lambda i: len(i), reverse=1)
	need = ans[0]
	delete = len(need)
	do = s
	k -= 1
	for i in range(n):
		if s[:i] == need:
			break
	add = s[i:]
	for i in range(k):
		do += add
	print(do)
solve()


import math
(n, k) = map(int, input().strip().split())
t = input()
h = 0
for i in range(1, n):
	if t[i:] == t[:n - i]:
		h = 1
		break
m = 1
s = t
if not h:
	i = n
while m < k:
	s = s + t[n - i:]
	m += 1
print(s)


(n, k) = (int(i) for i in input().split())
substr = input()
answer = substr
if n == 1:
	print(substr * k)
else:
	for i in range(k - 1):
		start = len(answer) - n + 1
		end = n - 1
		for j in range(n - 1):
			if answer[start:].find(substr[:end]) != -1:
				answer += substr[end:]
				break
			elif end == 1:
				answer += substr
			start += 1
			end -= 1
	print(answer)


(n, k) = map(int, input().split())
s = input()
i = n - 2
while i > -1:
	if s[:i + 1] == s[len(s) - i - 1:len(s)]:
		break
	i -= 1
if i == -1:
	print(s * k)
else:
	print(s, end='')
	print(s[i + 1:len(s)] * (k - 1))


(n, k) = map(int, input().split(' '))
s = input()
if n == 1:
	q = ''
	for i in range(k):
		q = q + s
	print(q)
else:
	q = s
	w = s
	j = n - 1
	c = 0
	for i in range(n - 1):
		if q[j:] == w[:n - j]:
			c = 1
			f = i
		j = j - 1
	if c == 1:
		q = s
		k = k - 1
		for i in range(k):
			q = q + s[f + 1:]
		print(q)
	else:
		q = ''
		for i in range(k):
			q = q + s
		print(q)


def problem(in1, in2):
	inputs = list(map(int, in1.split()))
	n = inputs[0]
	k = inputs[1]
	s = in2
	skip = n - 1
	while skip >= 0:
		end = s[skip:]
		ss = s[-skip:] + end
		if ss == s:
			break
		skip -= 1
	return s + end * (k - 1)
in1 = input()
in2 = input()
result = problem(in1, in2)
print(result)


from math import ceil
(n, k) = map(int, input().split())
s = input()
fl = 0
j = 0
for i in range(1, n):
	if s[:i] == s[-i:]:
		j = i + 1
print(k * s[:n - j + 1] + s[n - j + 1:])


(n, k) = map(int, input().split())
t = input()
p = 0
for i in range(1, n):
	if t[i:n] == t[0:n - i]:
		p = n - i
		break
print(t + (k - 1) * t[p:n])


(n, k) = map(int, input().split())
t = input()
com = 0
for i in range(1, len(t)):
	if t[:i] == t[-i:]:
		com = i
print(t + t[com:] * (k - 1))


def get_i(st, n):
	for i in range(1, n):
		if st[:len(st) - i] == st[i:]:
			return i
	return len(st)
l = input().split(' ')
(n, k) = (int(l[0]), int(l[1]))
st = input()
print(st, end='')
i = get_i(st, n)
st = st[len(st) - i:]
for i in range(1, k):
	print(st, end='')
print()


(n, k) = map(int, input().split())
t = input()
double = 0
for i in range(1, n):
	if t[-i:] == t[:i]:
		double = i
print(t + t[double:] * (k - 1))


(n, k) = [int(t) for t in input().split()]
t = input()
result = t * k
for l in range(1, n):
	ss = t[:l]
	if n % l == 0:
		if ss * (n // l) == t:
			c = t + ss * (k - 1)
			if len(c) < len(result):
				result = c
	r = t[-l:]
	if ss == r:
		m = t[l:-l] if l * 2 < n else ''
		r = r if l * 2 < n else t[l:]
		c = t + (m + r) * (k - 1)
		if len(c) < len(result):
			result = c
print(result)


(n, k) = [int(i) for i in input().split(' ')]
s = input()
l = []
a = ''
aa = s
for i in range(1, n):
	x = s[i:]
	if s[0:len(x)] == x:
		a = x
		aa = s[len(x):]
		break
print(s + (k - 1) * aa)


(n, k) = map(int, input().split())
a = list(input())
f = 0
for i in range(1, n):
	if a[i] == a[0]:
		c = a[i:]
		x = len(c)
		if a[:x] == c:
			f = 1
			break
if f == 0:
	ans = a * k
else:
	s = a[:i]
	ans = s * k
	ans += c
print(*ans, sep='')


(N, K) = map(int, input().split())
t = input()
i = 1
l = 0
while i < len(t):
	if t[:i] == t[-i:]:
		l = i
	i += 1
r = t + t[l:] * (K - 1)
print(r)


(n, k) = [int(x) for x in input().split()]
s = input()
i = 1
l = 0
while i < len(s):
	if s[:i] == s[-i:]:
		l = i
	i += 1
print(s + s[l:] * (k - 1))


import sys
input = sys.stdin.readline

def read():
	return list(map(int, input().split()))
(n, k) = read()
s = input()[:-1]
ans = ''
for i in range(len(s) + 1, 0, -1):
	res = s
	end = s[-i:]
	for j in range(k - 1):
		res += end
	cnt = 0
	for j in range(len(res) - len(s) + 1):
		if res[j:j + len(s)] == s:
			cnt += 1
	if cnt == k:
		ans = res
print(ans)


(n, k) = map(int, input().split(' '))
t = input()
i = 1
ans = 0
while i < n:
	if t[:i] == t[-i:]:
		ans = i
	i += 1
print(t[:ans], end='')
while k > 0:
	print(t[ans:], end='')
	k -= 1


(n, k) = map(int, input().split())
t = input().strip()
s = ''

def overlappingPart(a):
	for i in range(1, n):
		if all((t[j - i] == t[j] for j in range(i, n))):
			return t[n - i:]
	return t[:]
r = overlappingPart(t)
print(t + (k - 1) * r)


(n, m) = map(int, input().split())
a = input()
i = 1
while a[i:] != a[:-i]:
	i += 1
print(a[i:] + a[-i:] * m)


(n, k) = [int(i) for i in input().split()]
s = input()
s2 = ''
for i in range(n - 1, 0, -1):
	l = n - i
	if s[:l] == s[i:]:
		s2 = s[i:]
if s2 == '':
	print(s * k)
else:
	s3 = s[len(s2):]
	if k == 1:
		print(s)
	else:
		print(s + (k - 1) * s3)


(n, k) = map(int, input().split())
t = input()
i = n - 1
f = True
while f and i > 0:
	if t[len(t) - i:len(t)] == t[:i]:
		f = False
	i -= 1
s = ''
i += 1
if i == 1 and f:
	for i in range(k):
		s += t
	print(s)
else:
	print(t, end='')
	for j in range(k - 1):
		s += t[i:]
	print(s)


from collections import *
(n, k) = map(int, input().split())
s = input()
ind = n
for i in range(1, n):
	if s[:n - i] == s[i:]:
		ind = i
		break
t = s + s[n - ind:] * (k - 1)
print(t)


def lps(pattern):
	pattern = '#' + pattern
	length = len(pattern)
	table = [0 for i in range(length)]
	table[1] = 0
	for i in range(2, length):
		j = table[i - 1]
		while pattern[j + 1] != pattern[i] and j > 0:
			j = table[j]
		if pattern[j + 1] == pattern[i]:
			table[i] = j + 1
	return table

def solve(t, k):
	if k == 1:
		return t
	table = lps(t)
	p = table[-1]
	if p == 0:
		return t * k
	s = t[:-p]
	return s * k + t[-p:]
(n, k) = map(int, input().split())
t = input()
print(solve(t, k))


(n, k) = map(int, input().split())
t = input()
p = [0] * n
for i in range(1, n):
	j = p[i - 1]
	while j > 0 and t[j] != t[i]:
		j = p[j - 1]
	if t[i] == t[j]:
		j += 1
	p[i] = j
x = n - p[-1]
f = t[:x] * (k - 1) + t
print(f)


(n, k) = map(int, input().split(' '))
t = input()
s = set()
for c in t:
	s.add(c)
if len(s) == 1:
	print(t, end='')
	for i in range(k - 1):
		print(t[0], end='')
	print('')
else:
	suffixsize = 0
	for i in range(n - 1, 0, -1):
		if t[:i] == t[-i:]:
			suffixsize = i
			break
	if suffixsize > 0:
		print(t, end='')
		for i in range(k - 1):
			print(t[-(n - suffixsize):], end='')
		print('')
	else:
		for i in range(k):
			print(t, end='')
		print('')


(n, k) = map(int, input().split())
t = input()
ogt = t
n = len(t)
i = 1
while i < n:
	if t[i:] == t[:n - i]:
		break
	else:
		i += 1
zz = t[n - i:]
print(t + (k - 1) * zz)


(n, k) = [int(x) for x in input().split()]
t = input()
st = 0
s = ''
for i in range(1, n):
	if t[i:] == t[:n - i]:
		st = i
		break
if st == 0:
	s = t * k
else:
	s = t[:st] * (k - 1) + t
print(s)


def solve(n, m, k):
	period = 0
	ans = ''
	for i in range(1, n):
		if m[:i] == m[-i:]:
			period = i
	ans = m + m[period:] * (k - 1)
	print(ans)
(n, k) = map(int, input().split())
m = input()
solve(n, m, k)


(n, k) = map(int, input().split())
a = input()
idx = -1
for i in range(n - 1):
	t = a[:i + 1]
	if a.endswith(t):
		idx = i + 1
if idx == -1:
	idx = 0
print(a, end='')
for i in range(k - 1):
	print(a[idx:], end='')


(n, k) = map(int, input().split())
t = input()
if k == 1:
	print(t)
else:
	s = t
	m = len(t)
	ms = t
	for i in range(1, n):
		for j in range(i, n):
			if t[j] != t[j - i]:
				break
		else:
			m = i
			break
	print(t[:], end='')
	for i in range(k - 1):
		print(t[-m:], end='')


(n, k) = [int(i) for i in input().split()]
t = input()
t1 = t
g = 0
for i in range(1, n):
	if t[:i] == t[-i:]:
		g = i
if g != 0:
	t1 = t[g:]
for i in range(k - 1):
	t += t1
print(t)


(n, k) = map(int, input().strip().split())
s = input()
x = ''
pos = -1
i = 0
for i in range(n - 1):
	temp = s[:i + 1]
	if temp == s[n - 1 - i:]:
		x = temp
		pos = n - 1 - i
if pos == -1:
	print(s * k)
else:
	extra = s[pos:]
	raw = s[:pos]
	print(raw * k + extra)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
ttt = 1
for tt in range(ttt):
	(n, k) = map(int, sys.stdin.readline().split(' '))
	t = str(input())
	ans = t
	rr = 0
	for i in range(1, n):
		if t[i:] == t[:n - i]:
			rr = len(t[i:])
			break
	r = ''
	i = n - 1
	while len(r) != len(t) - rr:
		r += t[i]
		i -= 1
	r = r[::-1]
	ans += r * (k - 1)
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


(tam, q) = [int(i) for i in input().split()]
t = input()
s = t
posi = -1
for j in range(tam - 1):
	if t[:j + 1] == t[tam - j - 1:]:
		posi = j
add = t[posi + 1:]
for j in range(q - 1):
	s += add
print(s)


(n, k) = map(int, input().split())
t = input()
max_sub = n - 1
while t[:max_sub] != t[n - max_sub:]:
	max_sub -= 1
print(t + t[max_sub:] * (k - 1))


(n, k) = map(int, input().split())
t = input()
merge_index = None
for i in range(1, n):
	if t[i:] == t[:-i]:
		merge_index = i
		break
if merge_index is not None:
	res = []
	for i in range(k):
		res.append(t[:merge_index])
	res.append(t[merge_index:])
else:
	res = [t] * k
print(''.join(res))


(n, k) = map(int, input().split())
t = input()
startIndex = 0
for i in range(1, n + 1):
	startIndex = i
	fined = True
	for j in range(0, n - i):
		if t[j] != t[j + i]:
			fined = False
			break
	if fined:
		break
if n == 1:
	print(t[0] * k)
else:
	print(t[0:n - startIndex] + t[n - startIndex:n] * k)


(n, m) = list(map(int, input().split()))
t = input()
ind = 0
for i in range(1, n):
	if t[i:] == t[:n - i]:
		ind = n - i
		break
print(t + t[ind:] * (m - 1))


s = input().split()
n = int(s[0])
k = int(s[1]) - 1
s = input()
line = '' + s
add = s
for i in range(1, n):
	if s[i:] == s[:n - i]:
		add = s[n - i:]
		break
for i in range(k):
	line += add
print(line)


(n, k) = map(int, input().split())
s = input()
f = max((s[i:] for i in range(1, n + 1) if s[:n - i] == s[i:]))
res = s + s[len(f):] * (k - 1)
print(res)


(n, k) = [int(x) for x in input().split()]
s = input()

def get_min_length(s):
	min = n
	for i in range(1, n):
		if s[n - i:] == s[:i]:
			min = n - i
	return min
l = get_min_length(s)
r = []
if k > 0:
	r.append(s)
r.extend([s[-l:]] * (k - 1))
print(''.join(r))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007

def lps(s):
	arr = [0] * len(s)
	(i, j) = (1, 0)
	while i < len(s):
		if s[i] == s[j]:
			arr[i] = j + 1
			j += 1
		else:
			while j > 0 and s[i] != s[j]:
				j = arr[j - 1]
			if s[i] == s[j]:
				arr[i] = j + 1
				j += 1
		i += 1
	return arr
(n, k) = iia()
t = is1()
common = lps(t)[-1]
res = t
for i in range(k - 1):
	res += t[common:]
print(res)


def main():
	(n, k) = map(int, input().split())
	t = input()
	i = 1
	while t[i:] != t[:-i]:
		i += 1
	res = t + t[-i:] * (k - 1)
	print(res)
main()


(n, k) = map(int, input().split())
(s, i) = (input(), n - 1)
while not s.endswith(s[:i]):
	i -= 1
print(s[:i] + s[i:] * k)


(n, k) = map(int, input().split())
s = input()
pos = 0
if n == 1:
	print(s * k)
	exit()
flag = True
for i in range(n - 1):
	if s[i] != s[i + 1]:
		flag = False
if flag:
	print(s + s[1] * (k - 1))
	exit()
for i in range(n - 1):
	if s[-i - 1:] == s[:i + 1]:
		pos = i + 1
print(s + s[pos:] * (k - 1))


def main():
	(n, k) = map(int, input().split())
	t = input()
	i = 1
	while i < len(t):
		if t[i:] == t[:-i]:
			break
		i += 1
	if i == len(t):
		print(k * t)
	else:
		print(t + (k - 1) * t[-i:])
main()


(n, k) = map(int, input().split())
t = input()
ans = ''
for i in t:
	ans += i
for i in range(1, k):
	j = 1
	fir = 0
	while j < len(t):
		if ans[len(ans) - j:] == t[:j]:
			fir = j
		j += 1
	for yy in range(fir, n):
		ans += t[yy]
print(ans)


nums = input()
w = input()
(a, b) = nums.split(' ')
corte = w
for i in range(int(a) - 1):
	if w[int(a) - 1 - i:] == w[:i + 1]:
		corte = w[i + 1:]
print(w + corte * (int(b) - 1))


(n, k) = map(int, input().split())
t = input()
ans = t
cnt = 1
pos = 1
while cnt < k:
	while pos <= len(ans):
		if ans[pos:] == t[:len(ans) - pos]:
			ans += t[len(ans) - pos:]
			cnt += 1
			if cnt >= k:
				break
		pos += 1
	if cnt < k:
		ans += t
print(ans)


(n, k) = map(int, input().split())
s = input()
p = [0] * n
mx = 0
for i in range(1, n):
	for j in range(i, n):
		if s[j] == s[j - i]:
			p[i] += 1
		else:
			break
	if i + p[i] == n:
		mx = p[i]
		break
print(s, end='')
s = s[mx:]
for i in range(k - 1):
	print(s, end='')


(n, k) = map(int, input().split())
t = input()
x = n
for i in range(1, n):
	for j in range(n - i):
		if t[j] == t[j + i]:
			Flag = True
		else:
			Flag = False
			break
	if Flag:
		x = i
		break
sub = (k - 1) * t[n - x:n]
print(t + sub)


(n, k) = map(int, input().split(' '))
t = input()
flag = False
for i in range(1, n):
	if t[i:] == t[:n - i]:
		print(t[:i] * k + t[i:])
		flag = True
		break
if not flag:
	print(t * k)


(n, k) = map(int, input().split())
string = list(input())
res = ''
max = -1
if n == 1:
	print(res.join(string * k))
else:
	jie = ''
	fu = ''
	for i in range(0, n - 1):
		string.reverse()
		jie = jie + string[i]
		chong = jie[::-1]
		string.reverse()
		fu = fu + string[i]
		if chong == fu:
			max = i
	for m in range(max + 1, n):
		res = res + string[m]
	string_str = ''
	print(string_str.join(string) + res * (k - 1))


(n, kk) = map(int, input().split())
zz = input()
z = [0 for i in range(n)]
l = 0
r = 0
for i in range(1, len(z)):
	if i > r:
		r = l = i
		while r < len(z) and zz[r] == zz[r - l]:
			r += 1
		z[i] = r - l
		r -= 1
	else:
		k = i - l
		if z[k] < r - i + 1:
			z[i] = z[k]
		else:
			l = i
			while r < len(z) and zz[r] == zz[r - l]:
				r += 1
			z[i] = r - l
			r -= 1
c = 0
f = 0
for i in range(len(z) - 1, -1, -1):
	if z[i] > 0:
		if len(z) - i == z[i]:
			c = max(c, z[i])
			f = 1
print(zz + (kk - 1) * zz[c:])


from math import ceil
(n, k) = map(int, input().split())
s = input()
d = ''
for i in range(n - 1):
	if s[:i + 1] == s[n - i - 1:n]:
		d = s[i + 1:n]
if d == '':
	d = s
print(s, end='')
for i in range(1, k):
	print(d, end='')


(n, k) = [int(x) for x in input().split()]
s = input()
for i in range(1, n):
	if s[i:] == s[:n - i]:
		print(s + s[n - i:] * (k - 1))
		exit()
print(s * k)


k = list(map(int, input().split()))
j = k[0] - 1
l = input()
s = list(l)
m = set(s)
t = 0
c = 0
if len(m) == k[0]:
	print(l * k[1])
elif len(m) == 1:
	print(l + (k[1] - 1) * l[0])
else:
	for i in range(1, k[0] - 1):
		if l[0:i] == l[k[0] - i:]:
			c = i
	if c != 0:
		print(l + l[c:j + 1] * (k[1] - 1))
	else:
		print(l * k[1])


(n, k) = input().split()
n = int(n)
k = int(k)
t = input()
start = 0
for i in range(1, n):
	if t[0:n - i] == t[i:]:
		start = n - i
		break
print(t, end='')
for i in range(k - 1):
	print(t[start:], end='')


import sys
(n, k) = map(int, sys.stdin.readline().split())
t = input()
lst = [0]
for i in range(1, len(t)):
	if t[:i] == t[-i:]:
		lst.append(i)
a = lst[-1]
print(t + (k - 1) * t[a:])


def inline():
	return [int(n) for n in input().split()]
lst = inline()
l = lst[0]
n = lst[1]
s = input()
same = 0
for i in range(l - 1, 0, -1):
	if s[:i] == s[-i:]:
		same = i
		break
diff = s[-l + same:]
for j in range(n - 1):
	s += diff
print(s)


(n, k) = map(int, input().split())
t = input()
x = n - 1
while t[:x] != t[n - x:]:
	x -= 1
print(t + t[x:] * (k - 1))


(n, k) = map(int, input().split())
t = input()
if n == 1:
	print(t * k)
else:
	i = len(t) - 1
	while i > 0 and t[-i:] != t[:i]:
		i -= 1
	t2 = t[i:]
	print(t + t2 * (k - 1))


(n, k) = map(int, input().split())
s = input()
c = n
for i in range(1, n):
	if s[:n - i] == s[i:]:
		c = i
		break
s += (k - 1) * s[n - c:]
print(s)


from sys import stdin, stdout
(n, k) = [int(x) for x in stdin.readline().rstrip().split()]
t = stdin.readline()
for i in range(n):
	if t[0:i] == t[n - i:n]:
		s = t[0:n - i]
print(s * (k - 1) + t)


import math
str1 = input()
(n, k) = list(map(lambda x: int(x), str1.split(' ')))
t = list(input())
count = -1
for i in range(1, n):
	if t[0:i] == t[n - i:n]:
		count = i
mystr = ''
part1 = ''
part2 = ''
for elem in t[0:n - count]:
	part1 += str(elem)
for elem in t[n - count:n]:
	part2 += str(elem)
for i in range(k):
	mystr += part1
mystr += part2
print(mystr)


(n, k) = (int(x) for x in input().split())
t = input()
t1 = ''
for i in range(1, n + 1):
	if t[:n - i] == t[i:]:
		t1 += t[:i] * k
		t1 += t[i:]
		print(t1)
		break


read = lambda : map(int, input().split())
(n, k) = read()
s = input()
com = 0
for i in range(1, n):
	if s[n - i:] == s[:i]:
		com = i
ans = s
for i in range(1, k):
	ans += s[com:]
print(ans)


(x, y) = map(int, input().split())
s = input()
flag = 0
for i in range(1, len(s)):
	r = s[i:]
	if s[0:len(r)] == r:
		flag = 1
		break
if flag == 0:
	print(s * y)
else:
	print(s + (y - 1) * s[len(r):])


(n, k) = map(int, input().split())
s = list(input())
a = done = i = b = total = c = 0
while i < n:
	if i != 0:
		if done == 0:
			if s[i] == s[0]:
				a += 1
				done = 1
			i += 1
		elif s[i] == s[a]:
			a += 1
			if c == 0:
				if s[i] == s[0]:
					total = 1
					b = i
					c += 1
			i += 1
		else:
			if total == 1:
				i = b
				c = 0
				total = 0
			a = 0
			done = 0
	else:
		i += 1
l = ''
count = 0
y = n - a
x = y * k
i = 0
while count != x:
	if i == y:
		i = 0
	l += s[i]
	i += 1
	count += 1
for i in range(a):
	l += s[i]
print(l)


(n, k) = map(int, input().split())
s = input()
z = 0
y = 0
x = 0
y = 0
for i in range(n - 1):
	if s[0:i + 1] == s[n - i - 1:n]:
		if i + 1 > y:
			y = i + 1
for i in range(k - 1):
	s += s[y:n]
print(s)


def solve():
	(n, k) = map(int, input().split())
	t = input()
	if n == 1 or k == 1:
		print(t * k)
		return
	for i in range(1, n):
		if n % i == 0:
			c = t[:i]
			if c * (n // i) == t:
				print(c * (n // i + (k - 1)))
				return
	s = t
	h = n // 2
	for i in range(n):
		if n % 2 == 1:
			if s[:h - i + 1] == s[h + i:]:
				s = s[h - i + 1:]
				break
		elif s[:h - i] == s[h + i:]:
			s = s[h - i:]
			break
	print(t + s * (k - 1))
solve()


(n, k) = [int(i) for i in input().split()]
t = input()
i = 1
ti = 0
while i != n:
	if t[:i] == t[n - i:]:
		ti = i
	i += 1
s = t[0]
f = 1
for j in t:
	if j != s:
		f = 0
		break
if ti == 0:
	print(t * k)
elif f:
	print(t + (k - 1) * t[-1])
else:
	print(t + t[ti:] * (k - 1))


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, k) = I()
s = input().strip()
l = 0
ad = ''
for i in range(n - 1, 0, -1):
	pre = s[:i]
	su = s[n - i:]
	if su == pre:
		l = i
		break
ad = s[l:]
an = s + ad * (k - 1)
print(an)


def get_next(t, nxt):
	t = ' ' + t
	i = 1
	j = 0
	nxt[1] = 0
	m = len(t) - 1
	while i < m:
		if j == 0 or t[i] == t[j]:
			i += 1
			j += 1
			nxt[i] = j
		else:
			j = nxt[j]
	return nxt[m]
(n, k) = map(int, input().split())
t = str(input())
nxt = [0] * (len(t) + 1)
length = get_next(t, nxt)
if t[length - 1] != t[-1]:
	if t[0] == t[-1]:
		length = 1
	else:
		length = 0
print(t[0:n - length] * k + t[n - length:n])


def eq(s):
	for i in range(1, len(s)):
		if s[:len(s) - i] == s[i:]:
			return (s[-1 * i:], s[i:])
	return ('', s)
(n, k) = map(int, input().split(' '))
s = input()
(t, s) = eq(s)
if t == '':
	t = s * (k - 1)
else:
	t = t * k
print(s + t)


(n, k) = input().split(' ')
mot = input()
n = int(n)
k = int(k)
max = 0
for i in range(1, n):
	if mot[:i] == mot[-i:]:
		max = i
s = mot
print(mot + (k - 1) * mot[max:])


(n, k) = map(int, input().split())
w = input()
flag = False
for i in range(len(w) - 1, 0, -1):
	if w[:i] == w[n - i:]:
		flag = True
		break
if flag == False:
	print(w * k)
else:
	print(w, end='')
	print(w[i:] * (k - 1))


(n, k) = map(int, input().split())
s = input()
for pref_len in range(1, n + 1):
	if (s[:pref_len] + s).startswith(s):
		t = s[:pref_len]
		break
print(t * (k - 1) + s)


(n, k) = map(int, input().split())
t = input()
if n == 1:
	print(t * k)
	exit(0)
i = n - 2
j = 1
while j < n:
	if t[:i + 1] == t[j:]:
		break
	i -= 1
	j += 1
if t[:i + 1] == t[j:]:
	print(t + (k - 1) * t[i + 1:])
else:
	print(k * t)


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

def findi(s):
	i = 1
	while s[i:] != s[:n - i]:
		i += 1
	return i
i = findi(s)
print(s[:i] * (k - 1) + s)


(N, K) = [int(x) for x in input().split()]
string = input()
for i in range(len(string) - 1, 0, -1):
	if string[0:i] == string[len(string) - i:]:
		k = i
		break
else:
	k = 0
print(string + (K - 1) * string[k:])


(n, k) = map(int, input().split())
s = input()
fl = 1
for u in range(n - 1, -1, -1):
	if s[:u] == s[-u:]:
		fl = 0
		print(s[:-u] * k + s[-u:])
		break
if fl:
	print(s * k)


(t, n) = map(int, input().split())
st = input()
et = ''
st2 = ''
for i in range(t - 1):
	temp = st[i + 1:]
	st2 = st + temp
	if st2.find(st, 1) != -1:
		et = temp
if et == '':
	et = st
res = st
for i in range(n - 1):
	res += et
print(res)