#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 6;
const long long MOD = 1e9 + 7;
long long p2[N];
int main() {
  p2[0] = 1;
  for (int i = (int)(1), _b = (int)(N - 1); i <= _b; ++i)
    p2[i] = p2[i - 1] * 2 % MOD;
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> start;
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (u + 1 == v) continue;
    if (v - u != k + 1) {
      cout << 0 << endl;
      return 0;
    }
    start.push_back(u);
  }
  sort(start.begin(), start.end());
  long long res;
  if (start.size()) {
    if (start[start.size() - 1] - start[0] >= k + 1) {
      cout << 0 << endl;
      return 0;
    }
    res = 0;
    for (int i = (int)(1), _b = (int)(start[0]); i <= _b; ++i) {
      if (*start.rbegin() - i >= k + 1) continue;
      int m = min(n - k - 1, i + k);
      cerr << m << endl;
      m = m - i + 1 - start.size();
      if (i != start[0]) --m;
      res += p2[m];
      if (res > MOD) res -= MOD;
    }
  } else {
    res = 1;
    for (int i = (int)(1), _b = (int)(n - k - 1); i <= _b; ++i) {
      int m = min(n - k - 1, i + k);
      m = m - i + 1;
      res += p2[m - 1];
      if (res > MOD) res -= MOD;
    }
  }
  cout << res << endl;
  return 0;
}
