#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000000 + 10;
const int Mod = (int)1e9 + 7;
int n, m, k;
int is[MAX];
int sum[MAX];
int p2[MAX];
int main() {
  int i, a, b;
  scanf("%d%d%d", &n, &m, &k);
  if (k >= n) k = 0;
  if (k == 0) {
    printf("1\n");
    return 0;
  }
  p2[0] = 1;
  for ((i) = (1); (i) != (MAX); ++(i)) p2[i] = p2[i - 1] * 2 % Mod;
  ++k;
  for ((i) = (1); (i) <= (m); ++(i)) {
    scanf("%d%d", &a, &b);
    if (b != a + 1 && b != a + k) {
      printf("0\n");
      return 0;
    }
    if (b == a + k) is[a] = 1;
  }
  for ((i) = (1); (i) <= (n); ++(i)) sum[i] = is[i] + sum[i - 1];
  for ((i) = (1); (i) <= (n); ++(i))
    if (i + k <= n && is[i] && sum[n] - sum[i + k - 1] > 0) {
      printf("0\n");
      return 0;
    }
  long long ans = 1;
  for ((i) = (1); (i) <= (n); ++(i)) {
    long long now = 1;
    if (i + k > n) break;
    int l = min(i + k - 1, n - k);
    if (sum[n] - sum[l] > 0 || sum[i - 1])
      now = 0;
    else
      now = p2[l - i - (sum[l] - sum[i])];
    if (is[i] && now) now = (now - 1 + Mod) % Mod;
    ans = (ans + now) % Mod;
  }
  cout << ans << endl;
  return 0;
}
