#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int is[1100000];
int tw[1100000];
int Pow(int a, int b) { return tw[b]; }
int tt = 0;
int sum[1100000];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  tw[0] = 1;
  for (int i = 1; i <= n; i++) tw[i] = tw[i - 1] * 2ll % 1000000007;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (b - a != 1 && b - a != k + 1) {
      printf("0\n");
      return 0;
    }
    if (b - a == k + 1) {
      is[a] = 1;
      tt++;
    }
  }
  int Min, Max;
  Min = n;
  Max = 0;
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + is[i];
  for (int i = 1; i <= n; i++)
    if (is[i]) {
      Min = i;
      break;
    }
  for (int i = n; i >= 1; i--)
    if (is[i]) {
      Max = i;
      break;
    }
  if (!Max) {
    int res = 1;
    for (int i = 1; i <= n; i++) {
      int v = k;
      if (n - k - i - 1 < k) v = n - k - i - 1;
      if (v < 0) continue;
      res = (res + Pow(2, v)) % 1000000007;
    }
    printf("%d\n", res);
    return 0;
  }
  int res = 0;
  for (int i = 1; i <= Min; i++) {
    if (i + k + 1 <= Max) continue;
    int len = min(k, (n - k - 1) - i);
    len -= tt;
    if (i == Min) len++;
    res = (res + Pow(2, len)) % 1000000007;
  }
  printf("%d\n", res);
  return 0;
}
