# Rhyme solution codechef

Let’s say that two strings  and  rhyme if both strings have length at least , and their last  characters are equal. For example, if , the strings abcd and cebcd rhyme, the strings ab and ab don’t rhyme, the strings aaaa and aaaaa rhyme, the strings abcd and abce don’t rhyme.

You have  pairs of strings , and for each pair of strings you know, should they rhyme or should not.

Find all possible non-negative integer values for  such that pairs that have to rhyme, rhyme and pairs that must not rhyme, don’t rhyme.

## Input Rhyme solution codechef

Each test contains multiple test cases. The first line contains the number of test cases  (). Description of the test cases follows.

The first line of each test case contains a single integer  () — the number of string pairs.

Next  lines contains descriptions of pairs — one per line. The -th line contains space-separated strings  and  and marker . Strings are non-empty, consist of lowercase Latin letters and each have length at most . The marker  equals to  if strings have to rhyme, or  if they must not rhyme.

It’s guaranteed that for each test case there is at least one pair with  equal to  and that the total length of all strings over all test cases doesn’t exceed .

### Output Rhyme solution codechef

For each test case, firstly print integer  — the number of possible non-negative integer values of  such that pairs that have to rhyme, rhyme and pairs that must not rhyme, don’t rhyme. Next, print all these values of  (without repetitions). You can print them in any order.

Example
input

### Copy Rhyme solution codechef

3
1
kotlin heroes 1
2
join kotlin 1
episode eight 0
4
abc abcdef 0
xyz zzz 1
aaa bba 0
c d 0

output

### Copy Rhyme solution codechef

1
0
2
1 2
0


### Note Rhyme solution codechef

In the first test case, if  is at least  then kotlin and heroes don’t rhyme.

In the second test case, for  join and kotlin rhyme, and episode and eight don’t rhyme.