#include <bits/stdc++.h>
using namespace std;
long long pp2[1000001];
void pre() {
  pp2[0] = 1;
  for (int i = 1; i < 1000001; i++) pp2[i] = (pp2[i - 1] * 2) % 1000000007;
}
long long p2(int e) {
  if (e < 0) return 0;
  return pp2[e];
}
int main() {
  pre();
  int N, M, K;
  cin >> N >> M >> K;
  vector<int> s;
  for (int i = 0, a, b; i < M; i++) {
    cin >> a >> b;
    if (a + 1 == b) continue;
    if (a + K + 1 != b) {
      cout << "0";
      return 0;
    }
    s.push_back(a);
  }
  long long tot = 1;
  if (s.size() > 0) {
    if (s[s.size() - 1] - s[0] > K) {
      cout << "0";
      return 0;
    }
    int pt = K + 1 - s.size();
    if (pt > 0) {
      int p = p2(pt) - 1;
      bool first = true;
      for (int i = max(s[s.size() - 1] - K, 1); i <= s[0]; i++)
        if (N >= i + 2 * K + 1) {
          tot = (tot + p) % 1000000007;
          p = p2(pt - 1);
          first = false;
        } else if (first) {
          int t = K + 1 - s.size() - (i + 2 * K + 1 - N);
          p = p2(t) - 1;
          first = false;
          tot = (tot + p) % 1000000007;
        }
    }
  } else {
    if (N >= 2 * (K + 1))
      tot = (tot + (p2(K + 1) - 1 + 1000000007)) % 1000000007;
    else {
      if (N - K - 1 > 0)
        tot = (tot + (p2(N - K - 1) - 1 + 1000000007)) % 1000000007;
      else {
        cout << "1";
        return 0;
      }
    }
    int pl = p2(K);
    for (int i = K + 2; i <= N - K - 1; i++)
      if (i + K + 1 <= N) tot = (tot + pl) % 1000000007;
  }
  cout << tot;
  return 0;
}
