#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  for (c = getchar(); !(c >= '0' && c <= '9'); c = getchar())
    ;
  n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
}
int Pow(int base, int n, int mo) {
  if (n == 0) return 1;
  if (n == 1) return base % mo;
  int tmp = Pow(base, n >> 1, mo);
  tmp = (long long)tmp * tmp % mo;
  if (n & 1) tmp = (long long)tmp * base % mo;
  return tmp;
}
const int maxn = 1200000;
long long power[maxn], ans;
int N, M, K, x, y, s[maxn], v[maxn];
const int mo = 1000000007;
int main() {
  power[0] = 1;
  for (int i = (1); i <= (1000000); ++i) power[i] = power[i - 1] * 2 % mo;
  scanf("%d%d%d", &N, &M, &K);
  for (int i = (1); i <= (M); ++i) {
    scanf("%d%d", &x, &y);
    if (y != x + 1 && y != x + K + 1) {
      puts("0");
      return 0;
    }
    if (y == x + K + 1) s[x] = v[x] = 1;
  }
  for (int i = (1); i <= (N); ++i) s[i] += s[i - 1];
  for (int i = (1); i <= (N); ++i)
    if (v[i] && i + K + 1 <= N && s[N] - s[i + K]) {
      puts("0");
      return 0;
    }
  for (int last = (1); last <= (N); ++last)
    if (last + K + 1 <= N) {
      if (s[N] - s[last] == 0 && (s[max(last - K - 1, 0)] == 0)) {
        int bottom = max(last - K - 1, 0);
        int cnt = last - 1 - bottom - (s[last - 1] - s[bottom]);
        ans = (ans + power[cnt]) % mo;
      }
    }
  if (s[N] == 0) ans = (ans + 1) % mo;
  printf("%lld\n", ans);
  return 0;
}
