Codeforces Round 770 (Div. 2)
A
Reverse and Concatenate
Codeforces
800
原题
←B →
翻译中…

Real stupidity beats artificial intelligence every time.— Terry Pratchett, Hogfather, Discworld

翻译中…

You are given a string $s$ of length $n$ and a number $k$. Let's denote by $rev(s)$ the reversed string $s$ (i.e. $rev(s) = s_n s_{n-1} ... s_1$). You can apply one of the two kinds of operations to the string:

翻译中…
  • replace the string $s$ with $s + rev(s)$
  • replace the string $s$ with $rev(s) + s$
翻译中…

How many different strings can you get as a result of performing exactly $k$ operations (possibly of different kinds) on the original string $s$?

翻译中…

In this statement we denoted the concatenation of strings $s$ and $t$ as $s + t$. In other words, $s + t = s_1 s_2 ... s_n t_1 t_2 ... t_m$, where $n$ and $m$ are the lengths of strings $s$ and $t$ respectively.

翻译中…

Input

翻译中…

The first line contains one integer $t$ ($1 \le t \le 100$) — number of test cases. Next $2 \cdot t$ lines contain $t$ test cases:

翻译中…

The first line of a test case contains two integers $n$ and $k$ ($1 \le n \le 100$, $0 \le k \le 1000$) — the length of the string and the number of operations respectively.

翻译中…

The second string of a test case contains one string $s$ of length $n$ consisting of lowercase Latin letters.

翻译中…

Output

翻译中…

For each test case, print the answer (that is, the number of different strings that you can get after exactly $k$ operations) on a separate line.

翻译中…

It can be shown that the answer does not exceed $10^9$ under the given constraints.

翻译中…

Note

翻译中…

In the first test case of the example:

翻译中…

After the first operation the string $s$ can become either aabbaa or baaaab. After the second operation there are 2 possibilities for $s$: aabbaaaabbaa and baaaabbaaaab.

翻译中…

样例

Input #1
4
3 2
aab
3 3
aab
7 1
abacaba
2 0
ab
Output #1
2
2
1
1
InputCopy OutputCopy
题目信息
题号
1634A
时间限制
1 s
内存限制
256 MB
标签
贪心
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。