#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int beg = -1, en = -1;
int cnt = 0;
int two[1001000];
int const mod = 1e9 + 7;
void out() {
  cout << "0\n";
  exit(0);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  two[0] = 1;
  for (int i = 1; i <= n; ++i) two[i] = two[i - 1] * 2 % mod;
  for (int a, b, i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    --a, --b;
    if (b - a != 1 && b - a != k + 1) out();
    if (b - a == k + 1) {
      if (en == -1) en = b;
      beg = a;
      ++cnt;
    }
  }
  if (beg == -1) {
    int ans = 1;
    for (int i = 0; i + k + 1 < n; ++i) {
      int res = min(i + k, n - k - 2);
      ans = (ans + two[res - i]) % mod;
    }
    cout << ans << "\n";
    return 0;
  }
  if (beg >= en) out();
  int ans = 0;
  for (int i = 0; i + k + 1 < en; ++i) {
    int res = min(i + k, n - k - 2);
    res -= i;
    res -= cnt;
    if (beg < i + k + 1 && res >= 0) ans = (ans + two[res]) % mod;
  }
  int res = min(en - 1, n - k - 2);
  res -= en - k - 1;
  res -= cnt - 1;
  ans = (ans + two[res]) % mod;
  cout << ans << "\n";
}
