#include <bits/stdc++.h>
using namespace std;
int po[1000005], a[1000005], an = 0;
int m2pow(int x) { return po[x]; }
int main() {
  int n, m, k, ta, tb, flag = 0;
  po[0] = 1;
  for (int i = 0; i <= 1000000; i++) po[i + 1] = (po[i] * 2) % (1000000007);
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &ta, &tb);
    if (tb != ta + 1 && tb != ta + k + 1) flag = 1;
    if (!flag && tb == ta + k + 1) {
      a[an++] = ta;
    }
  }
  if (an > 0 && a[0] + k + 1 <= a[an - 1]) flag = 1;
  if (flag) {
    printf("0\n");
    return 0;
  }
  int l, r;
  long long ans = 1;
  if (an > 0) {
    for (int i = 1; i <= n; i++) {
      l = i, r = ((i + k) < (n - k - 1) ? (i + k) : (n - k - 1));
      if (l <= r && l <= a[0] && r >= a[an - 1]) {
        if (l == a[0])
          ans = (ans + (1000000007) - 1 + m2pow(r - l + 1 - an)) % (1000000007);
        else
          ans = (ans + m2pow(r - l - an)) % (1000000007);
      }
    }
    printf("%d\n", (int)ans);
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    l = i, r = ((i + k) < (n - k - 1) ? (i + k) : (n - k - 1));
    if (r >= l) ans = (ans + m2pow(r - l)) % (1000000007);
  }
  printf("%d\n", (int)ans);
}
