#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int C = 26;
void add(int &x, int y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
}
int fix(int x) {
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
int pw(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    b >>= 1;
    a = 1ll * a * a % MOD;
  }
  return ret;
}
const int MAXN = 1e6 + 10;
int n, m, k, vec[MAXN], sec[MAXN];
void solve() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    if (b != a + 1 && b != a + k + 1) {
      cout << "0\n";
      return;
    }
    if (b == a + k + 1) {
      vec[a] = 1;
    }
  }
  int L = n, R = -1;
  for (int i = 0; i < n; i++) {
    if (vec[i]) {
      L = min(L, i);
      R = max(R, i);
    }
  }
  for (int i = 0; i < n; i++) {
    sec[i + 1] = sec[i] + vec[i];
  }
  if (R - L > k) {
    cout << "0\n";
    return;
  }
  int ans = 1;
  for (int i = 0; i < n - k - 1; i++) {
    int my_R = min({i + k, n - k - 2, L + k});
    if (max(R, my_R) - min(i, L) > k) continue;
    if (vec[i]) continue;
    int my_edges = (my_R - i) - (sec[my_R + 1] - sec[i]);
    if (my_edges < 0) continue;
    add(ans, pw(2, my_edges));
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int te = 1;
  for (int w = 1; w <= te; w++) {
    solve();
  }
  return 0;
}
