This page is still under construction.

Parts of this page are still being built. What you see may change.

Sanggeun's travels

Time limit1sMemory limit256 MB

Summary
Given a connected graph of N countries and M flights, find the fewest flights that visit every country.
Level

Easy2 of 10

Topics
Graph
Solved
No attempts yet

Problem

Sanggeun decided to spend the winter break traveling through NN countries and finding himself. He is scared of planes he has never been on, so he wants to ride as few kinds of planes as possible while moving between countries.

Given the flight schedule for this break, find the smallest number of plane kinds Sanggeun needs in order to visit every country.

On the way from one country to another he may pass through other countries, including ones he has already visited.

Input

The first line contains the number of test cases TT. (T≤100T \le 100)

Each test case is given as follows.

  • The first line contains the number of countries NN and the number of plane kinds MM. (2≤N≤10002 \le N \le 1000, 1≤M≤100001 \le M \le 10000)
  • Each of the next MM lines contains two integers aa and bb, meaning there is a plane that flies back and forth between aa and bb. (1≤a,b≤N1 \le a, b \le N, a≠ba \ne b)

The given flight schedule always forms a connected graph.

Output

For each test case, print on one line the minimum number of plane kinds Sanggeun has to ride to travel to every country.

Examples1

  1. Example 1

    Input
    2
    3 3
    1 2
    2 3
    1 3
    5 4
    2 1
    2 3
    4 3
    4 5
    
    Expected output
    2
    4