#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAXN = 1000010;
int n;
int s[MAXN], p2[MAXN];
void prepare() {
  p2[0] = 1;
  for (int i = 0; i < (MAXN - 1); ++i) {
    p2[i + 1] = p2[i] + p2[i];
    if (p2[i + 1] >= MOD) p2[i + 1] -= MOD;
  }
}
int main() {
  prepare();
  int n, m, k;
  while (~scanf("%d%d%d", &n, &m, &k)) {
    ++k;
    memset(s, 0, sizeof(s));
    int minu = n, maxu = -1;
    bool flag = false;
    for (int i = 0; i < (m); ++i) {
      int u, v;
      scanf("%d%d", &u, &v);
      if (v - u == 1 || flag) continue;
      if (v - u != k) {
        flag = true;
        continue;
      }
      maxu = max(maxu, u);
      minu = min(minu, u);
      ++s[u];
      ++s[v];
    }
    if (maxu - minu >= k) flag = true;
    if (flag) {
      puts("0");
      continue;
    }
    for (int i = 0; i < (n); ++i) s[i + 1] += s[i];
    int L = max(1, maxu - k + 1), R = min(n - k, minu + k - 1), ans = 1;
    for (int i = L; i <= R; ++i) {
      if (i + k > n) break;
      if (s[i] - s[i - 1]) continue;
      int ps = min(i + k - 1, R), cnt = (ps - i) - (s[ps] - s[i]);
      ans += p2[cnt];
      if (ans >= MOD) ans -= MOD;
    }
    cout << ans << endl;
  }
  return 0;
}
