#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;
int v[MAXN] = {0};
int s[MAXN] = {0};
int N, M, K;
int F, T, L, R;
void calc() {
  for (int i = 1; i <= N; i++) s[i] += s[i - 1] + v[i];
}
int Pow(int x, int e) {
  int r = 1;
  for (; e; e >>= 1, x = (long long)x * x % MOD)
    if (e & 1) r = (long long)r * x % MOD;
  return r;
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  L = N;
  R = 0;
  for (int i = 1; i <= M; i++) {
    scanf("%d%d", &F, &T);
    if (F + 1 == T) continue;
    if (F + K + 1 != T) {
      printf("0\n");
      return 0;
    }
    v[F] = 1;
    L = min(L, F);
    R = max(R, F);
  }
  if (R - L > K) {
    printf("0\n");
    return 0;
  }
  calc();
  long long ans = 0;
  if (R == 0) {
    ans++;
    R++;
  }
  for (int i = R; i <= min(L + K, N - K - 1); i++) {
    if (i - K - 1 >= 0)
      ans += Pow(2, min(K, i - 1) - (s[i - 1] - s[i - K - 1]));
    else
      ans += Pow(2, min(K, i - 1) - s[i - 1]);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
