#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000006;
const int MOD = 1000000007;
int n, m, k, v, u, suma[MAXN], potega[MAXN], jest[MAXN];
long long res;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  while (m--) {
    scanf("%d %d", &u, &v);
    if (v - u == 1) continue;
    if (v - u != k + 1) return printf("0\n"), 0;
    jest[u] = 1;
  }
  suma[0] = 0;
  for (int i = (1); i <= (n); i++) suma[i] = suma[i - 1] + jest[i];
  potega[0] = 1;
  for (int i = (1); i <= (n); i++) potega[i] = (potega[i - 1] * 2) % MOD;
  if (suma[n] == 0) res++;
  for (int i = 1; i + k + 1 <= n; i++) {
    if (suma[i - 1] > 0 || suma[i + k] < suma[n]) continue;
    int pr = min(i + k, n - k - 1);
    int opcji = (pr - i) - (suma[pr] - suma[i]);
    res += potega[opcji];
  }
  res %= MOD;
  if (res < 0) res += MOD;
  cout << res << "\n";
  return 0;
}
