#include <bits/stdc++.h>
long long int _min(long long int x, long long int y) { return x < y ? x : y; }
long long int _max(long long int x, long long int y) { return x > y ? x : y; }
long long int modpow(long long int x) {
  long long int p = 1, s = 2;
  for (; x; x >>= 1) {
    if (x & 1) (p *= s) %= 1000000007;
    (s *= s) %= 1000000007;
  }
  return p;
}
void gi(long long int &x) {
  char ch = getchar();
  x = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
}
void fail() {
  printf("0");
  exit(0);
}
long long int n, m, k, smax, smin, p = 0, l, ans = 0;
int main() {
  long long int a, b;
  gi(n);
  gi(m);
  gi(k);
  smin = n - k - 1;
  while (m--) {
    gi(a);
    gi(b);
    if (b - a != 1 && b - a != k + 1) fail();
    if (b - a == k + 1) {
      if (a < smin) smin = a;
      if (a > smax) smax = a;
      p++;
    }
  }
  if (smax - smin > k) fail();
  n = n - k - 1;
  if (n <= 0) {
    printf("1");
    return 0;
  }
  for (l = _max(smax - k, 1); l <= smin; l++)
    (ans += modpow(_min(n, l + k) + 1 - l - p - (l == smin ? 0 : 1))) %=
        1000000007;
  printf("%d", int(ans % 1000000007));
  return 0;
}
