P12766 [HackerEarth] range sum for mapping of large ranges to small ranges
普及
题目描述

There are a total of n people in Prateek's class, numbered from 1 to n.
Every person has some field of interest for their projects.
There are a number people who have the same field of interest.
Now, you are given a number of pairs of the form (x,y).
This means that the students numbered x and y have interest in the same field.
You task is to form groups, such that, all the people with the same field of interest are in the same group.
No, member can be a member of more than one group.
From each group, the proctor picks exactly two students and if the group has only one student, then, only one student is picked.
These students will be responsible for submitting the progress report to the mentor.
Calculate the number of ways in which these students can be picked. As the answer can be large, print it modulo 1000000007

NOTE: These pairs are transitive, and symmetric.

INPUT
The first line of input contains the number of test cases. Description of a test case is given below.
1.The first line of each test case contains two space separated integers n and k,
the number of people and the number of pairs, respectively.

2.Then k lines follow, each containing 2 space separated integers x and y.
This means that people numbered x and y have interest in the same field.

OUTPUT
The output t lines, one for each test case. Each line contains the required answer for that test case.

CONSTRAINTS
1 ≤ t ≤ 5
1 ≤ n,k ≤ 100000
1 ≤ x,y ≤ n

SAMPLE INPUT
1
6 4
1 2
2 3
4 5
2 6

SAMPLE OUTPUT
6

输入格式

见题面

输出格式

见题面

样例输入
1 6 4 1 2 2 3 4 5 2 6 SAMPLE
样例输出
6