Codeforces
CF Step
Youtube Linkedin Discord Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Statement : Alternating Path

D. Alternating Path

You are given an undirected graph with n vertices and m edges. Vertices are numbered from 1 to n. The graph has no self-loops or multiple edges.

Your task is to assign a direction to each edge. After directing the edges, a sequence of vertices v1,v2,,vk (with k arbitrary and repetition allowed) is an alternating path if:

  • the edge (v1,v2) is directed from v1 to v2;
  • the edge (v2,v3) is directed from v3 to v2;
  • the edge (v3,v4) is directed from v3 to v4;
  • the edge (v4,v5) is directed from v5 to v4;
  • and so on (alternating forward / backward along the sequence).

A vertex v is beautiful if every path in the original graph that starts at v is an alternating path in the resulting directed graph.

What is the maximum number of vertices that can be made beautiful after directing the edges?


Input

The first line contains the number of test cases t (1t104).

Each test case has:

  • A line with two integers n and m (1n2105; 0m2105) — number of vertices and edges.
  • m lines, each with two integers v and u (1v,un) — an edge between v and u.

Additional constraints: no self-loops or multiple edges; the sum of n over all test cases does not exceed 2105; the sum of m over all test cases does not exceed 2105.


Output

For each test case, print one integer — the maximum number of vertices that can be made beautiful.


Example

Input

4
8 9
1 3
1 4
2 3
2 4
5 6
6 7
7 8
8 5
6 8
4 0
6 2
1 5
2 3
1 0

Output

2
4
4
1