#include <bits/stdc++.h>
using namespace std;
int m2pow(int x) {
  long long ans = 1, p = 2;
  while (x) {
    if (x & 1) ans = (ans * p) % (1000000007);
    p = (p * p) % (1000000007);
    x /= 2;
  }
  return ans;
}
int main() {
  int n, m, k, ta, tb, flag = 0;
  vector<int> a;
  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.push_back(ta);
    }
  }
  if (a.size() > 0 && *a.begin() + k + 1 <= *a.rbegin()) flag = 1;
  if (flag) {
    printf("0\n");
    return 0;
  }
  int l, r;
  long long ans = 1;
  if (a.size() > 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.begin() && r >= *a.rbegin()) {
        if (l == *a.begin())
          ans = (ans + (1000000007) - 1 + m2pow(r - l + 1 - a.size())) %
                (1000000007);
        else
          ans = (ans + m2pow(r - l - a.size())) % (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);
}
