#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int a[1000005], n, m, k;
long long pow2[1000005] = {1};
long long powmod(int n) {
  long long res = 1, a = 2;
  while (n) {
    if (n & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 1; i < n; ++i) {
    pow2[i] = pow2[i - 1] << 1;
    if (pow2[i] > MOD) pow2[i] -= MOD;
  }
  int u, v;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v;
    if (v == u + 1)
      continue;
    else if (v == u + k + 1) {
      a[u] = 1;
    } else {
      cout << 0 << '\n';
      return 0;
    }
  }
  for (int i = 2; i <= n; ++i) a[i] += a[i - 1];
  long long ans = 0LL;
  if (a[n] == 0) ans += 1;
  for (int i = n - k - 1; i > 0; --i) {
    if (a[n] == a[i + k] && a[i - 1] == a[0]) {
      int r = min(i + k, n - k - 1);
      int edges = a[r] - a[i];
      ans = (ans + pow2[r - i - edges]) % MOD;
    } else if (a[i] != a[i - 1] && a[n] > a[i + k]) {
      cout << 0 << '\n';
      return 0;
    }
  }
  cout << ans << '\n';
  return 0;
}
