Lucky Cities

Time limit1sMemory limit128 MB

Summary
Given an undirected graph, count vertices that lie on at least one simple cycle of odd length.
Level

Medium7 of 10

Topics
Graph, DFS, Union-find
Solved
No attempts yet

Problem

John has recently arrived in Romania for the South Eastern European Regional competition. Since John has never been to Romania before, the hosts decided to organize a sightseeing tour for him. Such a tour includes several Romanian cities, and none of them is visited more than once. John starts in one city, visits some other cities according to a guided route, and at the end of the tour returns to the starting point.

There are NN cities numbered from 1 to NN and MM two-way roads in the country. Each road connects two different cities. A sightseeing tour for John is a sequence of cities c1,c2,…,cnc_1, c_2, \dots, c_n such that all cic_i are distinct, cic_i and ci+1c_{i+1} are connected by a road for i=1,2,…,n−1i = 1, 2, \dots, n-1, and cnc_n and c1c_1 are connected by a road as well.

Being an odd person, John would like to visit an odd number of cities. The organizers have drawn the plans of all possible tours with an odd number of cities, and only such tours are considered.

The residents of a city would love John to visit them. A city is called lucky if there is at least one such tour (with an odd number of cities) passing through it. Your task is to compute the number of lucky cities in Romania.

Input

The first line of input contains a single integer TT — the number of test cases. Every test case starts with a line containing two integers separated by a single space — NN and MM. Each of the next MM lines contains two integers aia_i and bib_i separated by a single space — the labels of the cities that the ii-th road connects.

Output

The output should contain TT lines — the answer for each of the test cases, in order.

Constraints

  • 1≤T≤771 \le T \le 77
  • 0≤N,M≤1050 \le N, M \le 10^5
  • 1≤ai<bi≤N1 \le a_i < b_i \le N

Examples1

  1. Example 1

    Input
    1
    7 7
    1 5
    3 5
    3 7
    1 7
    6 7
    4 7
    4 6
    
    Expected output
    3