#include <bits/stdc++.h>
using namespace std;
vector<int> gr[1000001];
long long mem[1000001];
long long bd = 1000000007;
long long po(int n) {
  if (n == 0) return 1;
  if (mem[n] != 0) return mem[n];
  long long r1 = po(n / 2);
  r1 *= r1;
  r1 %= bd;
  if (n % 2) r1 *= 2;
  r1 % bd;
  mem[n] = r1;
  return r1;
}
int freea[1000001];
bool ford[1000002];
int fordm = 10000001;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i < n; i++) {
    gr[i].push_back(i + 1);
  }
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (u != v - 1) {
      if ((v - u) != k + 1) {
        cout << 0;
        return 0;
      } else {
        gr[u].push_back(v);
        fordm = min(fordm, v);
      }
    }
  }
  for (int i = n; i >= 0; i--) {
    ford[i] = ((ford[i + 1]) | (gr[i].size() == 2));
  }
  for (int i = 1; i <= n; i++) {
    freea[i] =
        ((gr[i].size() == 1) && (i + k + 1 <= n) && (i < fordm)) + freea[i - 1];
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int d = i + k + 1;
    if (d > n) break;
    if (gr[i].size() > 1) {
      if (ford[d]) {
        cout << 0;
        return 0;
      }
    } else {
      if (!ford[d] && i < fordm) {
        int d1 = freea[i];
        int d2 = freea[d];
        d2 += (!((d + k + 1 <= n) && (d < fordm)));
        ans += po(d2 - d1 - 1);
        ans %= bd;
      }
    }
  }
  cout << (ans + 1) % bd;
  return 0;
}
