ONBRIDGE - Online Bridge Searching

Given a graph of N vertices, numbered from 0 to N - 1. Initially, there is no edge in the graph. Sequentially adding M undirected edges (u, v) to the graph (0 <= u, v <= N - 1). After adding an edge, you must print out the current number of bridges in the graph. The data guarantees that there is no request to add an existed edge, or an edge from a vertex to itself.

Input

The first line contains an integer T (T <= 10) denotes the number of test cases. Each test case begins with 2 integers N (1 <= N <= 50000) and M (1 <= M <= 100000), followed by M lines, each line contains a pair of integers (u, v) represents a request to add an edge (u, v) to the graph.

Output

After each request, print out the current number of bridges in the graph on a separate line.

Example

For the input data:

1
5 10
3 0
0 2
1 0
1 3
1 4
2 4
4 0
2 1
2 3
3 4

the correct result is:

1
2
3
1
2
0
0
0
0
0


Được gửi lên bởi:Race with time
Ngày:2012-03-06
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:C C++ 4.3.2 CPP CPP14

hide comments
2015-05-29 05:05:33 Dương Phạm Tùng
bai nhu l**
2015-05-29 03:32:34 Anh chỉ yêu mình anh........
Xin trích dẫn lại lời của Phong "Nguyên gay :v"
2015-05-29 03:08:33 Đừng Di Chuột Vào Đây
dm host
2015-05-29 03:06:03 Phong
Nguyên gay :v
2015-05-29 03:05:37 Natsu Kagami
đề khó vãi :(
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.