QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#7854. This is not a data structure problem

统计

Given an undirected graph with $n$ vertices and $m$ edges. The graph has no multiple edges or self-loops, and it is guaranteed to be connected.

For an edge connecting two vertices $(a, b)$, we define its associated interval as $(\min(a, b), \max(a, b))$ (an open interval).

A graph is defined as "good" if and only if for any two edges, their associated intervals are either nested or disjoint.

Find the number of ways to relabel the vertices (out of $n!$ possible permutations) such that the resulting graph is good.

The answer should be taken modulo $10^9+7$.

Input

The first line contains two positive integers $n$ and $m$, representing the number of vertices and edges in the graph.

The next $m$ lines each contain two integers $u_i$ and $v_i$, representing the $i$-th edge connecting vertices $u_i$ and $v_i$ before relabeling.

Output

Output a single positive integer representing the answer modulo $10^9+7$.

Examples

Input 1

4 5
1 2
1 3
2 3
3 4
2 4

Output 1

8

Input 2

6 5
1 2
1 3
3 4
3 5
3 6

Output 2

288

Input 3

4 6
1 2
1 3
1 4
2 3
2 4
3 4

Output 3

0

Constraints

For $100\%$ of the data, $1 \leq n, m \leq 2 \times 10^5$.

Subtask ID $n \leq$ $m \leq$ Special Property Score
$1$ $10$ $30$ None $5$
$2$ $2\times10^5$ $n-1$ None $5$
$3$ $2\times10^5$ $n$ None $5$
$4$ $300$ $1000$ The graph is good before relabeling $20$
$5$ $300$ $1000$ The answer is guaranteed to be non-zero modulo $10^9+7$ $20$
$6$ $300$ $1000$ $m=2n-3$ $20$
$7$ $300$ $1000$ None $10$
$8$ $2\times10^5$ $2\times10^5$ None $15$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.