- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Bob is studying at CoC university. Bob wants to make new friends. He thinks: "The friends of my friends can be my friends, too!". So if Bob and Joey are friends, and Joey and Frank are friends, then Bob and Frank can be friends, too. Bob wants to know how many people are there to be friends with. Bob is smart, Be like Bob!
ورودی
The first line of input shows the number of test cases $T$. $$1 \leq T \leq 100$$
Each test case starts with a line containing two space separated integers $N$ and $M$ indicating number of students and number of pairs of friends respectively. $$1 \leq N \leq 400, \quad \quad 0 \leq M \leq 5000$$ Each of the following $M$ lines consist of two space separated integers $A$ and $B$ which indicates that person $A$ and person $B$ are friends.
$$1 \leq A \neq B \leq N$$
There might be repetitive pairs in input. Bob is always number $1$.
خروجی
For each test case, print a single integer in a line denoting how many students are there for bob to be friends with.
مثالها
ورودی نمونه ۱
2
4 3
1 2
2 3
2 4
5 5
1 2
1 3
2 4
3 4
4 5
خروجی نمونه ۱
2
1
ارسال پاسخ برای این سؤال