#P8867. [NOIP2022] 建造军营

[NOIP2022] 建造军营

Description

Countries A and B are at war, and country A plans to build some military camps on its own territory.

Country A’s territory consists of nn cities, connected by mm bidirectional roads, such that any two cities are directly or indirectly reachable through the roads. Country A will choose one or more cities (at least one) and build exactly one military camp in each chosen city.

It is well known that communication between camps is crucial. However, country A has received intelligence that country B will soon attack one of A’s roads, but the exact target is unknown. If B’s attack succeeds, that road will be cut, which may cause some two camps in A to be unable to reach each other, something A is keen to avoid. Therefore, A decides to station troops to guard some roads (it could be one or more, or possibly none). Country A is confident that any guarded road can withstand B’s attack and will not be cut.

Country A wants to design a plan for building camps and guarding roads such that, no matter which road in A is attacked by B, it will not cause any two camps to be unable to reach each other. Please help country A calculate how many possible plans there are for building camps and guarding roads. Since the number of plans may be large, output the value modulo 1,000,000,007(109+7)1,000,000,007\left(10^{9}+7\right). Two plans are considered different if and only if there exists at least one city that has a camp in one plan but not in the other, or there exists at least one road that is guarded in one plan but not in the other.

Input Format

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

The next mm lines each contain two positive integers ui,viu_i, v_i, describing a bidirectional road connecting uiu_i and viv_i. There are no multiple edges or self-loops.

Output Format

Output one line containing an integer, the number of valid plans for building camps and guarding roads, modulo 1,000,000,007(109+7)1,000,000,007\left(10^{9}+ 7\right).

2 1
1 2
5
4 4
1 2
2 3
3 1
1 4
184
见附加文件里的 barrack/barrack3.in
见附加文件里的 barrack/barrack3.ans
见附加文件里的 barrack/barrack4.in
见附加文件里的 barrack/barrack4.ans

Hint

Sample 1 Explanation

In the sample, country A has two cities, with 11 road connecting them.

All possible plans are as follows:

  • Build a camp in city 11, do not guard the road.
  • Build a camp in city 11, guard the road.
  • Build a camp in city 22, do not guard the road.
  • Build a camp in city 22, guard the road.
  • Build camps in cities 1,21, 2, guard the road.

Constraints

For all testdata, it is guaranteed that 1n5×1051 \leq n \leq 5 \times 10^5, n1m106n - 1 \leq m \leq 10^6, 1ui,vin1 \leq u_i, v_i \leq n, uiviu_i \neq v_i.

Test point ID nn \leq mm \leq Special condition
131 \sim 3 88 1010 None
474 \sim 7 1616 2525 ^
898 \sim 9 30003000 50005000
101110 \sim 11 5×1055 \times 10^5 10610^6 Special property A\mathrm{A}
121412 \sim 14 ^ m=n1m = n - 1
151615 \sim 16 m=nm = n
172017 \sim 20 None

Special property A\mathrm{A}: guarantee m=n1m = n - 1 and the ii-th road connects city ii and i+1i + 1.

Translated by ChatGPT 5