#include <bits/stdc++.h>
using namespace std;
const long long N = 1000000 + 5;
const long long MOD = 1000000007;
long long n, m, k;
long long ans;
long long v[N], sum[N];
long long Pow(long long x, long long k) {
  long long z = 1;
  for (; k; k >>= 1, (x *= x) %= MOD)
    if (k & 1) (z *= x) %= MOD;
  return z;
}
int main() {
  scanf("%I64d %I64d %I64d", &n, &m, &k);
  long long a, b, flag = 0, st = 0, ed = 0;
  for (long long i = 1; i <= m; i++) {
    scanf("%I64d %I64d", &a, &b);
    if (a >= b) flag = 1;
    if (b - a == 1 || b - a == k + 1)
      ;
    else
      flag = 1;
    if (b - a == k + 1) {
      v[a] = 1;
      if (!st) st = a;
      ed = a;
    }
  }
  if (flag || (ed - st >= k + 1))
    printf("0\n");
  else {
    for (long long i = 1; i <= n; i++) sum[i] = sum[i - 1] + v[i];
    n -= ++k;
    for (long long i = 1; i <= n; i++)
      if (!st || (!v[i] && abs(i - st) + 1 <= k && abs(i - ed) + 1 <= k)) {
        long long tmp = st ? ((((i) < (st) ? (i) : (st)) + k - 1) < (n)
                                  ? (((i) < (st) ? (i) : (st)) + k - 1)
                                  : (n))
                           : n;
        long long r = ((k - 1) < (tmp - i) ? (k - 1) : (tmp - i));
        (ans += Pow(2, r - (sum[i + r] - sum[i]))) %= MOD;
      }
    printf("%I64d\n", ans + 1);
  }
  return 0;
}
