Bessie has a connected, undirected graph G with N vertices labeled 1…N and M edges (2≤N≤102,N−1≤M≤2N2+N). G may contain self-loops (edges from nodes back to themselves), but no parallel edges (multiple edges connecting the same endpoints).
Let f_G(a,b) be a boolean function that evaluates to true if there exists a path from vertex 1 to vertex a that traverses exactly b edges for each 1≤a≤N and 0≤b, and false otherwise. If an edge is traversed multiple times, it is included that many times in the count.
Elsie wants to copy Bessie. In particular, she wants to construct an undirected graph G′ such that f_G′(a,b)=f_G(a,b) for all a and b.
Your job is to count the number of distinct graphs G′ that Elsie may create, modulo 109+7. As with G, G′ may contain self-loops but no parallel edges (meaning that there are 22N2+N distinct graphs on N labeled vertices in total).
Each input contains T (1≤T≤4105) test cases that should be solved independently. It is guaranteed that the sum of N2 over all test cases does not exceed 105.
The first line of the input contains T, the number of test cases.
The first line of each test case contains the integers N and M.
The next M lines of each test case each contain two integers x and y (1≤x≤y≤N), denoting that there exists an edge between x and y in G.
Consecutive test cases are separated by newlines for readability.
For each test case, the number of distinct G′ modulo 109+7 on a new line.