#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long nr = 2e6 + 100;
inline long long read() {
  long long ret = 0;
  long long x = 1;
  char ch;
  while (!isdigit(ch)) {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + ch - '0';
    ch = getchar();
  }
  return ret * x;
}
inline long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
inline long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
inline long long max(long long a, long long b) { return a + b - min(a, b); }
long long n, m, k;
long long rd1, rd2;
long long ans = 0;
long long lef = 1e18;
long long righ = 0;
;
bool flag[nr] = {0};
long long cnt = 0;
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= m; i++) {
    rd1 = read();
    rd2 = read();
    if ((rd2 - rd1 == 1) || (rd2 - rd1 == k + 1)) {
      if (rd2 - rd1 == k + 1) {
        lef = min(lef, rd1);
        righ = max(righ, rd1);
        flag[rd1] = true;
        ++cnt;
      }
    } else {
      cout << 0;
      return 0;
    }
  }
  if (righ > 0 && (righ - lef) > k) {
    cout << 0;
    return 0;
  }
  if (righ > 0) {
    long long kk = 0;
    for (int i = max(1, righ - k); i <= lef; i++) {
      long long res = min(i + k, n - k - 1) - i - cnt;
      if (i == lef) res++;
      ans += power(2, res);
      ans %= mod;
    }
    cout << ans;
    return 0;
  } else {
    ans = 1;
    for (int i = 1; i <= n - k - 1; i++) {
      ans += power(2, min(n - k - 1, i + k) - i);
      ans %= mod;
    }
    cout << ans;
  }
  return 0;
}
