Thief

Time Limit: 1000 ms

Memory Limit: 65535 ms

Description

Many years later , xiaoyoulei start up a big company,the company has a lot of rooms
 layers of nested,it’s very beautiful,but it cause a problem that his staff are very easy to go wrong ways. what’s more ,once the door is locked , it’s easy to get lost.
The company layout like  the picture below:

In order to make up for his failure design on the room layout , xiaoyoulei make a decision that he will select some keys just in the corresponding rooms .(the arc in the picture means there is a door,for example the arc between room 1 and room 2means there is a door . The room where the arc locates there has the key . if the door is open ,you can get in both of the room from the other one . But if the door is locked ,because Room 2 has the key to open the lock , so from room 2 you can get through to room 1. But if you are in the room 1. You won’t get through to room 2.)
Xiao you lei has some bad habit,that he likes to put valuables in one room of the company. To show off his wealthiness , he also told others which room the valuables are there.
Here comes the problem , there are thieves in the company!
Now ,if we could tell you the room numbers where the thieves are there and the room numbers where the valuables are . Could you tell me how many doors we must lock at least to prevent the thieves to steal the valuables in the room . if no matter how many doors were locked ,we  can not prevent the thieves.(for example the thief is in room 3,the valuables are in room 2,than the thief can get the keys in room 3 to get in room 4, and get the key in room 4 to get in room 2. ),just call xiao you lei!

Input

The first line is a T,means the test case numbers。 For each test case. The first line is M and N (1 <=m<= 20; 0 <=n<= 19),M means how many rooms are there,N means where the valueables are there。 There are M more lines to indicate the condition of all the M rooms,the first letter in each line may be a T or an S,T means the room has a thief ,S means there isn’t has a thief 。(you may depend there are more than one thief and in different rooms ),than there is a number p (0 <=p <= 20) ,means the room has how many doors to get in other rooms,and has the key of the door。(example,if the first line below M and N comes “ S 2 2 3 “,it means room 1 don’t have a thief,it can go through to two rooms numbered ROOM 2 and ROOM 3,when the door is locked.ROOM 1 still can get through to ROOM 2 and ROOM 3)

Output

One integer means how many doors you need to lock or print a line “call new sister right now!”(not include the quotation mark)。

Sample Input

3
7 2
S 0
T 3 0 4 5
S 2 1 6
S 2 1 2
S 0
S 0
S 0
7 2
I 0
S 3 0 4 5
S 2 1 6
T 2 1 2
S 0
S 0
T 0
4 3
T 0
S 1 2
S 1 0
S 4 1 1 2 2

Sample Output

2
call new sister right now!
1

Hint

Source

bobo0906

提交代码