Codeforces Round 184 (Div. 2)
D
Olya and Graph
Codeforces
2200
原题
← CE →
翻译中…

Olya has got a directed non-weighted graph, consisting of $*n*$ vertexes and $*m*$ edges. We will consider that the graph vertexes are indexed from 1 to $*n*$ in some manner. Then for any graph edge that goes from vertex $*v*$ to vertex $*u*$ the following inequation holds: $*v* < *u*$.

翻译中…

Now Olya wonders, how many ways there are to add an arbitrary (possibly zero) number of edges to the graph so as the following conditions were met:

翻译中…
  1. You can reach vertexes number $*i* + 1, *i* + 2, ..., *n*$ from any vertex number $*i*$ $(*i* < *n*)$.
  2. For any graph edge going from vertex $*v*$ to vertex $*u*$ the following inequation fulfills: $*v* < *u*$.
  3. There is at most one edge between any two vertexes.
  4. The shortest distance between the pair of vertexes $*i*, *j*$ $(*i* < *j*)$, for which $*j* - *i* ≤ *k*$ holds, equals $*j* - *i*$ edges.
  5. The shortest distance between the pair of vertexes $*i*, *j*$ $(*i* < *j*)$, for which $*j* - *i* > *k*$ holds, equals either $*j* - *i*$ or $*j* - *i* - *k*$ edges.
翻译中…

We will consider two ways distinct, if there is the pair of vertexes $*i*, *j*$ $(*i* < *j*)$, such that first resulting graph has an edge from $*i*$ to $*j*$ and the second one doesn't have it.

翻译中…

Help Olya. As the required number of ways can be rather large, print it modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

Input

翻译中…

The first line contains three space-separated integers $*n*, *m*, *k*$ $(2 ≤ *n* ≤ 10^{6}, 0 ≤ *m* ≤ 10^{5}, 1 ≤ *k* ≤ 10^{6})$.

翻译中…

The next $*m*$ lines contain the description of the edges of the initial graph. The $*i*$-th line contains a pair of space-separated integers $*u*_{*i*}, *v*_{*i*}$ $(1 ≤ *u*_{*i*} < *v*_{*i*} ≤ *n*)$ — the numbers of vertexes that have a directed edge from $*u*_{*i*}$ to $*v*_{*i*}$ between them.

翻译中…

It is guaranteed that any pair of vertexes $*u*_{*i*}, *v*_{*i*}$ has at most one edge between them. It also is guaranteed that the graph edges are given in the order of non-decreasing $*u*_{*i*}$. If there are multiple edges going from vertex $*u*_{*i*}$, then it is guaranteed that these edges are given in the order of increasing $*v*_{*i*}$.

翻译中…

Output

翻译中…

Print a single integer — the answer to the problem modulo $1000000007$ $(10^{9} + 7)$.

翻译中…

Note

翻译中…

In the first sample there are two ways: the first way is not to add anything, the second way is to add a single edge from vertex $2$ to vertex $5$.

翻译中…

样例

Input #1
7 8 2
1 2
2 3
3 4
3 6
4 5
4 7
5 6
6 7
Output #1
2
InputCopy OutputCopy
Input #2
7 0 2
Output #2
12
InputCopy OutputCopy
Input #3
7 2 1
1 3
3 5
Output #3
0
InputCopy OutputCopy
题目信息
题号
305D
时间限制
2 s
内存限制
256 MB
标签
组合数学
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。