CF305D.Olya and Graph

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Olya has got a directed non-weighted graph, consisting of nn vertexes and mm edges. We will consider that the graph vertexes are indexed from 1 to nn in some manner. Then for any graph edge that goes from vertex vv to vertex uu 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,...,ni+1,i+2,...,n from any vertex number ii (i<n) .
  2. For any graph edge going from vertex vv to vertex uu 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,ji,j (i<j) , for which ji<=kj-i<=k holds, equals jij-i edges.
  5. The shortest distance between the pair of vertexes i,ji,j (i<j) , for which j-i>k holds, equals either jij-i or jikj-i-k edges.

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

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

输入格式

The first line contains three space-separated integers n,m,kn,m,k (2<=n<=106,0<=m<=105,1<=k<=106)(2<=n<=10^{6},0<=m<=10^{5},1<=k<=10^{6}) .

The next mm lines contain the description of the edges of the initial graph. The ii -th line contains a pair of space-separated integers ui,viu_{i},v_{i} (1<=u_{i}<v_{i}<=n) — the numbers of vertexes that have a directed edge from uiu_{i} to viv_{i} between them.

It is guaranteed that any pair of vertexes ui,viu_{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 uiu_{i} . If there are multiple edges going from vertex uiu_{i} , then it is guaranteed that these edges are given in the order of increasing viv_{i} .

输出格式

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

输入输出样例

  • 输入#1

    7 8 2
    1 2
    2 3
    3 4
    3 6
    4 5
    4 7
    5 6
    6 7
    

    输出#1

    2
    
  • 输入#2

    7 0 2
    

    输出#2

    12
    
  • 输入#3

    7 2 1
    1 3
    3 5
    

    输出#3

    0
    

说明/提示

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 22 to vertex 55 .

首页