#icpc2013autumnd. [icpc2013autumn_d]Everlasting -One-

[icpc2013autumn_d]Everlasting -One-

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

"Everlasting -One-" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play.

In this game, a character is characterized by attributes. There are NN attributes in this game, numbered 11 through NN. Each attribute takes one of the two states, light or darkness. It means there are 2N2^N kinds of characters in this game.

You can change your character by job change. Although this is the only way to change your character's attributes, it is allowed to change jobs as many times as you want.

The rule of job change is a bit complex. It is possible to change a character from AA to BB if and only if there exist two attributes aa and bb such that they satisfy the following four conditions:

  • The state of attribute aa of character AA is light.

  • The state of attribute bb of character BB is light.

  • There exists no attribute cc such that both characters AA and BB have the light state of attribute cc.

  • A pair of attribute (a,b)(a, b) is compatible.

Here, we say a pair of attribute (a,b)(a, b) is compatible if there exists a sequence of attributes c_1,c_2,ldots,c_nc\_1, c\_2, \\ldots, c\_n satisfying the following three conditions:

  • c_1=ac\_1 = a.

  • c_n=bc\_n = b.

  • Either (c_i,c_i+1)(c\_i, c\_{i+1}) or (c_i+1,c_i)(c\_{i+1}, c\_i) is a special pair for all i=1,2,ldots,n1i = 1, 2, \\ldots, n-1. You will be given the list of special pairs.

Since you love this game with enthusiasm, you are trying to play the game with all characters (it's really crazy). However, you have immediately noticed that one character can be changed to a limited set of characters with this game's job change rule. We say character AA and BB are essentially different if you cannot change character AA into character BB by repeating job changes.

Then, the following natural question arises; how many essentially different characters are there? Since the output may be very large, you should calculate the answer modulo 1,000,000,0071{,}000{,}000{,}007.


Input

The input is a sequence of datasets. The number of datasets is not more than 5050 and the total size of input is less than 55 MB.

Each dataset is formatted as follows.

NN MM
a_1a\_1 b_1b\_1
:
:
a_Ma\_M b_Mb\_M

The first line of each dataset contains two integers NN and MM (1leNle1051 \\le N \\le 10^5 and 0leMle1050 \\le M \\le 10^5). Then MM lines follow. The ii-th line contains two integers a_ia\_i and b_ib\_i (1lea_iltb_ileN1 \\le a\_i \\lt b\_i \\le N) which denote the ii-th special pair. The input is terminated by two zeroes.

It is guaranteed that (a_i,b_i)ne(a_j,b_j)(a\_i, b\_i) \\ne (a\_j, b\_j) if ineji \\ne j.

Output

For each dataset, output the number of essentially different characters modulo 1,000,000,0071{,}000{,}000{,}007.


Sample Input

3 2
1 2
2 3
5 0
100000 0
0 0```

### Output for the Sample Input

```plain
3
32
607723520```

* * *

### Source Name

[JAG Practice Contest for ACM-ICPC Asia Regional 2013](http://acm-icpc.aitea.net/index.php?2013%2FPractice%2F%CC%CF%B5%BC%C3%CF%B6%E8%CD%BD%C1%AA)

* * *