#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[1222222], sum[1222222];
long long p2[1222222];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (u == v - 1) continue;
    if (u + k + 1 != v) {
      cout << 0 << endl;
      return 0;
    }
    a[v] = 1;
  }
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  p2[0] = 1;
  for (int i = 1; i <= n; i++) p2[i] = (p2[i - 1] * 2) % 1000000007ll;
  long long ans = 0;
  if (sum[n] == 0) {
    ans = 1;
    for (int i = k + 2; i <= n; i++) {
      ans += p2[min(k - sum[i - 1], i - k - 2)];
      ans %= 1000000007ll;
    }
  } else {
    int l = 1, r = n;
    while (a[l] == 0) l++;
    while (a[r] == 0) r--;
    if (l + k >= r) {
      for (int i = r; i <= n && i <= l + k; i++) {
        int lef = max(k + 2, i - k);
        int rig = i - 1;
        ans += p2[(rig - lef + 1) - (sum[rig] - sum[lef - 1])];
        ans %= 1000000007ll;
      }
    }
  }
  ans %= 1000000007ll;
  cout << ans << endl;
}
