题库练习 The Overdosing Ubiquity
← 上一题 下一题 →

A11192 | The Overdosing Ubiquity

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

The fundamental prerequisite for justice is not to be correct, but to be strong. That's why justice is always the victor.

The Cinderswarm Bee. Koyomi knows it.

The bees, according to their nature, live in a tree. To be more specific, a complete binary tree with $n$ nodes numbered from $1$ to $n$ . The node numbered $1$ is the root, and the parent of the $i$ -th ( $2<=i<=n$ ) node is ![](/uploads/acgo/image/2219e6a362e4d49a_676b0480e9f2.jpeg). Note that, however, all edges in the tree are undirected.

Koyomi adds $m$ extra undirected edges to the tree, creating more complication to trick the bees. And you're here to count the number of simple paths in the resulting graph, modulo $10^{9}+7$ . A simple path is an alternating sequence of adjacent nodes and undirected edges, which begins and ends with nodes and does not contain any node more than once. Do note that a single node is also considered a valid simple path under this definition. Please refer to the examples and notes below for instances.

输入格式

The first line of input contains two space-separated integers $n$ and $m$ ( $1<=n<=10^{9}$ , $0<=m<=4$ ) — the number of nodes in the tree and the number of extra edges respectively.

The following $m$ lines each contains two space-separated integers $u$ and $v$ ( $1<=u,v<=n$ , $u≠v$ ) — describing an undirected extra edge whose endpoints are $u$ and $v$ .

Note that there may be multiple edges between nodes in the resulting graph.

输出格式

Output one integer — the number of simple paths in the resulting graph, modulo $10^{9}+7$ .

输入输出样例

输入 #1
3 0
输出 #1
9
输入 #2
3 1
2 3
输出 #2
15
输入 #3
2 4
1 2
2 1
1 2
2 1
输出 #3
12
C++ 编辑器
输入
输出