405927: GYM102163 B Let me sleep

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Let me sleeptime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Hasan is lazy. He likes to stay asleep in the morning. But the dorm's supervisor always wakes him up. He will try to run from her.

The dorm consists of $$$N$$$ rooms. There are $$$M$$$ portals between these rooms. To catch Hasan, the supervisor will stand at one of these portals. The supervisor can catch Hasan only if she stands in a portal between two rooms such that this portal is the only way to get between these two rooms.

Hasan can add one portal between any two rooms in the dorm; if he added it optimally, what is the minimum number of portals that the supervisor can use to catch him.

Input

First line of the input will be $$$T$$$, the number of test cases.

Each test case starts with a line of two numbers, $$$N$$$, $$$M$$$ ($$$ 1 \le N, M \le 10^5 $$$)the number of rooms and portals.

Next $$$M$$$ lines contain two integers, $$$u$$$ and $$$v$$$ the rooms of the $$$i_{th}$$$ portal($$$ 1 \le u, v \le N $$$).

Output

For each test case, print one line, the minimum number of portals that the supervisor can use to catch him.

ExampleInput
2
3 2
1 2
2 3
9 11
3 2
3 8
2 8
1 2
1 5
1 4
5 9
7 5
4 5
6 4
4 7
Output
0
1

Source/Category

加入题单

上一题 下一题 算法标签: