#include <bits/stdc++.h>
using namespace std;
long long int modulo = 1000000007;
const int limite = 1000001;
long long int elev[limite];
int ocupado[limite];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  elev[0] = 1;
  for (int i = 1; i < limite; i++) elev[i] = (elev[i - 1] * 2) % modulo;
  int ini = 0;
  int fin = n + 1;
  int inf = k + 2;
  int sup = n;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (v == u + 1)
      ;
    else if (v == u + k + 1) {
      ocupado[v] = 1;
      ini = max(ini, u);
      fin = min(fin, v);
      inf = max(inf, u + 1);
      sup = min(sup, v + k);
    } else {
      cout << 0 << endl;
      exit(0);
    }
  }
  if (fin <= ini) {
    cout << 0 << endl;
    exit(0);
  }
  int libres = 0;
  long long int maneras = 1;
  for (int i = inf; i <= sup; i++) {
    if (not ocupado[i]) {
      maneras = (maneras + elev[libres]) % modulo;
      libres++;
    }
    if (i - k >= inf and not ocupado[i - k]) libres--;
  }
  cout << maneras << endl;
}
