QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#5164. Building Military Camps

Statistics

Country A and Country B are in a fierce war, and Country A plans to build some military camps on its territory.

The territory of Country A consists of $n$ cities and $m$ bidirectional roads connecting these cities, such that any two cities can be reached from each other directly or indirectly. Country A plans to select one or more cities (at least one) and build a military camp in each of these cities.

As is well known, communication between military camps is very important. However, Country A has received intelligence that Country B will soon attack one of the roads in Country A, although the specific target is unknown. If Country B's attack is successful, this road will be cut off, which might cause two military camps in Country A to become unreachable from each other—a situation Country A desperately wants to avoid. Therefore, Country A has decided to send troops to guard several roads (it can be one or more, or even none at all). Country A is confident that the guarded roads can withstand Country B's attack and will not be cut off.

Country A hopes to develop a plan for building military camps and guarding roads such that no matter which road Country B attacks, it will not cause any two military camps to become unreachable from each other. Now, please help Country A calculate the number of possible plans for building military camps and guarding roads. Since the number of plans may be very large, you only need to output the result modulo $1,000,000,007 (10^9 + 7)$. Two plans are considered different if and only if there is at least one city that has a military camp in one plan but not in the other, or if there is at least one road that is guarded in one plan but not in the other.

Input

The input is read from the file barrack.in.

The first line contains two positive integers $n$ and $m$, representing the number of cities and the number of bidirectional roads, respectively.

The next $m$ lines each contain two positive integers $u_i, v_i$, describing a bidirectional road connecting $u_i$ and $v_i$. It is guaranteed that there are no multiple edges or self-loops.

Output

The output is written to the file barrack.out.

Output a single integer representing the number of plans for building military camps and guarding roads, modulo $1,000,000,007 (10^9 + 7)$.

Examples

Input 1

2 1
1 2

Output 1

5

Note 1

In the example, Country A has 2 cities and 1 road connecting them. All possible plans are as follows: Build a military camp in city 1, do not guard the road; Build a military camp in city 1, guard the road; Build a military camp in city 2, do not guard the road; Build a military camp in city 2, guard the road; * Build military camps in cities 1 and 2, guard the road.

Input 2

4 4
1 2
2 3
3 1
1 4

Output 2

184

Input 3

See barrack/barrack3.in and barrack/barrack3.ans in the contestant's directory.

Input 4

See barrack/barrack4.in and barrack/barrack4.ans in the contestant's directory.

Constraints

For all data, it is guaranteed that $1 \le n \le 5 \times 10^5$, $n - 1 \le m \le 10^6$, $1 \le u_i, v_i \le n$, and $u_i \neq v_i$.

Test Case ID $n \le$ $m \le$ Special Condition
1 ~ 3 8 10
4 ~ 7 16 25 None
8 ~ 9 3000 5000
10 ~ 11 $5 \times 10^5$ $10^6$ Special Property A
12 ~ 14 $5 \times 10^5$ $10^6$ $m = n - 1$
15 ~ 16 $5 \times 10^5$ $10^6$ $m = n$
17 ~ 20 $5 \times 10^5$ $10^6$ None

Special Property A: Guaranteed that $m = n - 1$ and the $i$-th road connects city $i$ and city $i + 1$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.