Lalo's Lawyer Lost#12932

Lalo's Lawyer Lost

While picking up Lalo's bail, Saul and Mike got lost in a desert. In a desert, they found a cactus: a connected undirected graph on nodes, such that every edge in it appears in at most one simple cycle.

It turned out that is even. For some reason, Mike and Saul want to solve the following problem:

Define d(u, v) as the shortest distance between nodes and in this cactus. Partition all nodes into \frac{n}{2} pairs (u_i, v_i), such that every node appears in exactly one pair, and the sum of d(u_i, v_i) is maximized.

What's the maximum possible sum of d(u_i, v_i) in such a partition?

Input

The first line contains a single integer (1 \le t \le 10^5)  — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers (2 \leq n \leq 2\cdot 10^5, n-1 \leq m \leq 4\cdot 10^5, is even)  — the number of nodes and edges correspondingly.

The -th of the next lines contains two integers u_i, v_i (1 \leq u_i, v_i \leq n, u_i \neq v_i)  — denoting an edge between nodes u_i and v_i. It's guaranteed that these edges form a cactus.

It is guaranteed that the sum of over all test cases does not exceed 2\cdot 10^5, and the sum of over all test cases does not exceed 4\cdot 10^5.

Output

For each test case, output a single integer  — the largest possible sum of d(u_i, v_i) in such a partition.

Examples

Example

Loading
Loading