#Lutece0609. Shaking Your Cellphone

Shaking Your Cellphone

Migrated from Lutece 609 Shaking Your Cellphone

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Do you know a software called "WeiXin", a kind of chatting tool? There is an application called "Shaking for a while". Once you shake your cellphone, you can find those who shake their cellphone at same time.

One day when Tom was shaking his cellphone, he thought about a problem: how large the friends group would be if everyone made friends once they find others who shake cellphone at same time and combine their friends group?

We assume all the people are lonely and have no friends at the beginning. In other word, their friends group only contains themselves.

Input

First line contains an integer TT (0<T100 < T \leq 10), indicate there are TT cases.

For each case, the first line contains an integer NN (0<N10000 < N \leq 1000), indicate the number of people who would shake their cellphone.

Then follows NN lines. Every line comes with an integer KiK_i (0Ki14400 \leq K_i \leq 1440), indicate the ithi_{th} person shakes cellphone KK times a day. Then follows KiK_i strings shown as HH:MM, indicate the time the ithi_{th} person shakes cellphone.

Output

For each test case, the first line contains an integer XX indicate how many friends group amount the people; the second line comes XX integers in nondescending order, indicate the scale of each friends group.

Samples

1
4
3 00:00 00:01 00:02
2 00:01 00:03
1 00:03
1 00:04
2
1 3

Resources

6th BUPT Programming Contest Final