#include <bits/stdc++.h>
using namespace std;
int n, m, K, x, y, P = 1e9 + 7, M[1000010], s[1000010];
bool vis[1000010];
void read(int &x) {
  char ch = getchar();
  int mark = 1;
  for (; ch != '-' && (ch < '0' || ch > '9'); ch = getchar())
    ;
  if (ch == '-') mark = -1, ch = getchar();
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
  x *= mark;
}
int main() {
  read(n);
  read(m);
  read(K);
  for (int i = 1; i <= m; i++) {
    read(x);
    read(y);
    if (y - x > 1) {
      if (y - x == K + 1)
        vis[x] = 1;
      else {
        printf("0\n");
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + vis[i];
  long long ans = (s[n] == 0);
  M[0] = 1;
  for (int i = 1; i <= n; i++) M[i] = M[i - 1] * 2 % P;
  for (int i = 1; i < n - K; i++)
    if (s[n] - s[i + K] == 0 && s[i - 1] == 0) {
      int t = s[i + K] - s[i] + 1;
      int can = min(K + 1, n - K - i);
      (ans += M[can - t]) %= P;
    }
  printf("%I64d\n", ans);
  return 0;
}
