Make Them Equal codeforces solution- Theofanis has a string s1s2…sns1s2…sn and a character cc. He wants to make all characters of the string equal to cc using the minimum number of operations. In one operation he can choose a number xx (1≤x≤n1≤x≤n) and for every position ii, where ii is not divisible by xx, replace sisi with cc. Find the minimum number of operations required to make all the characters equal to cc and the xx-s that he should use in his operations.

Make Them Equal codeforces solution

Theofanis has a string s1s2sns1s2…sn and a character cc. He wants to make all characters of the string equal to cc using the minimum number of operations.

In one operation he can choose a number xx (1xn1≤x≤n) and for every position ii, where ii is not divisible by xx, replace sisi with cc.

Find the minimum number of operations required to make all the characters equal to cc and the xx-s that he should use in his operations.

Make Them Equal solution codeforces

The first line contains a single integer tt (1t1041≤t≤104) — the number of test cases.

The first line of each test case contains the integer nn (3n31053≤n≤3⋅105) and a lowercase Latin letter cc — the length of the string ss and the character the resulting string should consist of.

The second line of each test case contains a string ss of lowercase Latin letters — the initial string.

It is guaranteed that the sum of nn over all test cases does not exceed 31053⋅105.

Make Them Equal solution codeforces

For each test case, firstly print one integer mm — the minimum number of operations required to make all the characters equal to cc.

Next, print mm integers x1,x2,,xmx1,x2,…,xm (1xjn1≤xj≤n) — the xx-s that should be used in the order they are given.

It can be proved that under given constraints, an answer always exists. If there are multiple answers, print any.

Example

input

Make Them Equal solution codeforces

3
4 a
aaaa
4 a
baaa
4 b
bzyx

Make Them Equal solution codeforces

Copy
0
1
2
2 
2 3
Note

Let’s describe what happens in the third test case:

  1. x1=2x1=2: we choose all positions that are not divisible by 22 and replace them, i. e. bzyx  bzbx;
  2. x2=3x2=3: we choose all positions that are not divisible by 33 and replace them, i. e. bzbx  bbbb.
  3. For Solution

    Click Here!

Leave a Reply

Your email address will not be published. Required fields are marked *

*