CAM5 - prayatna PR


help the Prayatna pr team

Well, the annual technical symposium of Department of Computer Technology is around the corner. All that we need, to make it a grand success is Publicity among the peer groups ( ofCourse the sponsors too :P ). We decided to share the job between the student groups. As per the plan we decided to meet people in person and influence them to attend Prayatna. But to meet them we have to go to various student groups. To do so, we had to cut our classes. But being studious. students refused to cut more classes. Instead of meeting every one in person we decided to meet few people such that the person to whom we pass the news will spread it to all his friends. And those friends will pass it to other friends and so on. Your task is to find the number of people to be met by the organizers to spread the news.

Caution: Large I/O

Input

First line of input is 't' - Test cases. Follwed by N, the number of peers in the testcase ( 0 to N-1 ). followed by the number of friend description 'e'. Following are 'e' descriptions of type "a b" denoting 'a' friends with 'b'. If 'a' is friends with 'b' then 'b' is friends with 'a'.

Output

Output contains t line, the number of people, the organizers have to meet in person for each test case.

Example

Input:
2

4
2
0 1
1 2

3
0

Output:
2
3

Explanation

case 1 : 0 is friends with 1; 1 is friends with 2; so if we pass the news to 0 & 3, news will pass it to the entire N peers.

case 2 : no one is friends with any one. So we have to meet every one in person.

Constraints

t = 10
2 <= N <= 100000
0 <= e <= N/2


hide comments
Kriti Joshi: 2014-12-11 05:54:37

First graph ques, AC in first attempt :)

yousef hadder: 2014-06-10 10:23:34

AC with 1.31 S
how can i get faster solution than this ??

JordanBelfort: 2014-05-31 12:45:40

easy if u understand it :)

Trilok Sharma: 2013-08-20 05:10:09

(Got Accepted)
Test case :-
input:
1

12
10
0 1
4 5
8 9
2 3
6 7
10 11
5 6
9 10
5 10
2 9

output:-
2

mani: 2013-06-09 14:28:05

@karthikeyan - any space between a&b? as in if a&b are 1 &2.. is it like 12 or 1<space>2 in the test case file ??

jalaj: 2013-05-31 13:08:31

too simple.. :)

Aradhya: 2013-05-16 12:02:29

kids. here is a treat for u.. for nursery school kids

MR. BEAN : 2012-12-16 13:28:19

185th user :D

karthikeyan: 2012-01-25 13:28:14

@AKJ no space between the test cases

AKJ: 2012-01-15 15:15:22

any space between the test cases?


Added by:karthikeyan
Date:2012-01-11
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:own problem