#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000005, mod = 1000000007;
int n, m, k, ans;
int cnt[Maxn], p[Maxn], tot = 0;
inline int get() {
  char ch;
  while (!isdigit(ch = getchar()))
    ;
  int v = ch - 48;
  while (isdigit(ch = getchar())) v = v * 10 + ch - 48;
  return v;
}
int main() {
  n = get();
  m = get();
  k = get();
  for (int i = 1, s, t; i <= m; i++) {
    s = get();
    t = get();
    if (t - s != 1 && t - s != k + 1) return puts("0"), 0;
    if (t - s == k + 1) ++cnt[s], ++tot;
  }
  ans += tot == 0;
  p[0] = 1;
  for (int i = 1; i <= n; i++)
    cnt[i] += cnt[i - 1], p[i] = (p[i - 1] << 1) % mod;
  for (int i = 1; i + k + 1 <= n; i++)
    if (cnt[i + k] - cnt[i - 1] == tot)
      ans =
          (ans + p[min(n - i - k, k + 1) - tot - (cnt[i] == cnt[i - 1])]) % mod;
  printf("%d\n", ans);
  return 0;
}
