Smudged Cat Strings
Gats the cat found a string of beads. The bead at position has the letter .
Gats wants to tie a loop by overlapping some beads from the left end with the same number of beads from the right end. A small smudge is allowed.
For a length with , Gats compares the first symbols, , with the last symbols, , in the same left-to-right order.
The length is called a smudged loop length if the two compared strings differ in at most one position, that is,
For each string, list all smudged loop lengths.
Input
The first line contains an integer (), the number of strings.
For each test case, the first line contains an integer (), the length of .
Output
For each test case, print two lines.
The first line contains an integer , the number of smudged loop lengths.
The second line contains integers in strictly increasing order: all valid values of . If , the second line must be empty.
Samples
Sample 1
Input
3 5 ababa 6 catcot 1 m
Output
2 1 3 2 1 3 0
For the first string, the valid values are and .
For the second string, the valid values are and ; when , the two compared ends differ in only one position.