#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007, N = 1000005;
int n, m, k, ans, degs[N];
inline int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
int main() {
  degs[0] = 1;
  for (int i = 0; i < (int)N; i++) {
    if (!i) continue;
    degs[i] = add(degs[i - 1], degs[i - 1]);
  }
  scanf("%d %d %d\n", &n, &m, &k);
  vector<pair<int, int> > edges;
  for (int i = 0; i < (int)m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (b - a != 1 && b - a != k + 1) {
      puts("0");
      return 0;
    }
    if (b - a == k + 1) edges.push_back(make_pair(a, b));
  }
  sort(edges.begin(), edges.end());
  m = edges.size();
  if (k == 0 || k >= n - 1) {
    puts("1");
    return 0;
  }
  for (int i = 0; i < (int)m; i++) {
    if (!(edges[i].first >= edges[0].first &&
          edges[i].first < edges[0].second)) {
      puts("0");
      return 0;
    }
  }
  if (edges.size() == 0) ++ans;
  for (int i = 0; i < (int)n; i++) {
    int f = i + 1, s = i + k + 2, cnt = m;
    if (s > n || (m > 0 && f > edges[0].first)) break;
    if (m > 0 && !(f <= edges[0].first && edges[m - 1].first < s)) continue;
    if (m > 0 && f == edges[0].first) cnt--;
    s = min(s, n - k);
    ans = add(ans, degs[s - f - cnt - 1]);
  }
  printf("%d\n", ans);
}
