#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int n, m, k;
long long pow2[1000002];
int f[1000002];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  pow2[0] = 1;
  for (int i = 0; i < (int)n + 1; i++) pow2[i + 1] = pow2[i] * 2 % MOD;
  vector<int> v;
  for (int i = 0; i < (int)m; i++) {
    int u, t;
    scanf("%d%d", &u, &t);
    if (u + 1 == t) continue;
    if (u + 1 + k != t) {
      cout << 0 << endl;
      return 0;
    }
    v.push_back(u - 1);
    f[u - 1] = 1;
  }
  sort(v.begin(), v.end());
  if (v.empty()) {
    long long ans = 1;
    for (int i = 0; i < (int)n - k - 1; i++) {
      ans = (ans + pow2[min(i + k, n - k - 2) - i]) % MOD;
    }
    cout << ans << endl;
  } else if (v[0] + k + 1 <= v.back()) {
    cout << 0 << endl;
  } else {
    long long ans = 1;
    for (int i = 0; i < (int)n - k - 1; i++) {
      if (i <= v[0] && v.back() <= i + k) {
        int kk =
            min(k, n - i - k - 2) - (upper_bound(v.begin(), v.end(), i + k) -
                                     upper_bound(v.begin(), v.end(), i));
        ans = (ans + pow2[kk] - f[i]) % MOD;
      }
    }
    cout << (ans + MOD) % MOD << endl;
  }
  return 0;
}
