CF1029A.Many Equal Substrings

传统题 时间 2000 ms 内存 256 MiB 7 尝试 3 已通过 1 标签

Many Equal Substrings

You are given a string tt consisting of nn lowercase Latin letters and an integer number kk.

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

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

It is guaranteed that the answer is always unique.

Input

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

The second line of the input contains the string tt consisting of exactly nn lowercase Latin letters.

Output

Print such string ss of minimum possible length that there are exactly kk substrings of ss equal to tt.

It is guaranteed that the answer is always unique.

Samples

3 4
aba
ababababa
3 2
cat
catcat

在线编程 IDE

建议全屏模式获得最佳体验