#include <bits/stdc++.h>
using namespace std;
const int N = 1100000, M = 1000000007;
int i, j, k, l, m, n, o, p, No, a[N], mi[N], s[N], f[N], c[N];
inline int read() {
  int o = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while ((c >= '0') && (c <= '9')) {
    o = o * 10 + c - '0';
    c = getchar();
  }
  return o;
}
inline void Init() {
  n = read();
  m = read();
  k = read();
  No = 0;
  for (i = 1; i <= m; i++) {
    o = read();
    p = read();
    l = p - o;
    if ((l != 1) && (l != (k + 1))) No = 1;
    if (l == (k + 1)) a[p] = 1;
  }
  mi[0] = 1;
  for (i = 1; i <= n; i++) {
    mi[i] = mi[i - 1] << 1;
    if (mi[i] >= M) mi[i] -= M;
  }
  for (i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  for (i = k + 2; i <= n; i++) {
    o = s[i - k - 1];
    l = i + k + 1;
    if (l > n) l = n + 1;
    p = s[n] - s[l - 1];
    f[i] = (!o) && (!p);
  }
  for (i = 1; i <= n; i++)
    if ((!f[i]) && a[i]) No = 1;
  for (i = 1; i <= n; i++) c[i] = c[i - 1] + (f[i] && (!a[i]));
}
inline int Solve() {
  int is = 1, ans = 0, now = 0, st;
  if (No) return 0;
  for (i = k + 2; i <= n; i++) {
    j = i + k;
    if (j > n) j = n;
    if (f[i] && (!s[i - 1])) {
      if (a[i]) is = 0;
      now = c[j] - c[i];
      ans += mi[now];
      if (ans >= M) ans -= M;
    }
  }
  return (ans + is) % M;
}
int main() {
  Init();
  cout << Solve() << endl;
  return 0;
}
