#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int mod = 1000000007;
int c[N];
int f[N];
vector<int> s;
int n, m, K;
void pre() {
  c[0] = 1;
  for (int i = 1; i < N; i++) {
    c[i] = (c[i - 1] * 2) % mod;
  }
}
bool check() {
  int si = s.size();
  if (si >= 2 && s[si - 1] - s[0] >= K) return true;
  return false;
}
void solve() {
  m = s.size();
  int ans = 0, t = min(n - K, K);
  if (m == 0) {
    ans = c[t];
    for (int i = K * 2 + 1; i <= n; i++) {
      ans = (ans + c[K - 1]) % mod;
    }
  } else {
    ans = c[t - m];
    for (int i = max(s[m - 1], K * 2) + 1; i <= n && i - s[0] < K; i++) {
      ans = (ans + c[K - 1 - m]) % mod;
    }
  }
  printf("%d\n", ans);
}
int main() {
  pre();
  int flag = 0;
  scanf("%d%d%d", &n, &m, &K);
  K++;
  for (int i = 0, u, v; i < m; i++) {
    scanf("%d%d", &u, &v);
    if (v - u != 1 && v - u != K) flag = 1;
    if (v - u == K) s.push_back(v);
  }
  if (flag || check()) {
    puts("0");
    return 0;
  }
  if (K >= n) {
    puts("1");
    return 0;
  }
  solve();
  return 0;
}
