#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int n, m, k;
vector<int> ser;
int tw[1000005];
int l, r;
int main() {
  tw[0] = 1;
  for (int i = 1; i < 1000005; i++) tw[i] = (tw[i - 1] + tw[i - 1]) % MOD;
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  while (m--) {
    cin >> l >> r;
    if (r - l != 1 && r - l != k + 1) {
      cout << "0";
      return 0;
    }
    if (r - l == k + 1) {
      ser.push_back(r);
    }
  }
  k++;
  if (ser.size() >= 2) {
    if (ser[ser.size() - 1] - ser[0] >= k) {
      cout << "0";
      return 0;
    }
  }
  if (k >= n) {
    cout << "1";
    return 0;
  }
  int m = ser.size();
  if (m == 0) {
    int ans = tw[min(n - k, k)];
    for (int i = k + k + 1; i <= n; i++) {
      ans += tw[k - 1];
      ans %= MOD;
    }
    cout << ans;
    return 0;
  }
  int ans = tw[min(n - k, k) - m];
  for (int i = max(ser[m - 1], 2 * k) + 1; i <= n && i - ser[0] < k; i++) {
    ans += tw[k - 1 - m];
    ans %= MOD;
  }
  cout << ans;
  return 0;
}
