#include <bits/stdc++.h>
const int P = 1e9 + 7;
const int N = 1e6 + 5;
inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
void add(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}
int n, m, k, x, y, cnt, a[N], ans, pw2[N];
std::pair<int, int> edge[N];
int main() {
  std::cin >> n >> m >> k;
  pw2[0] = 1;
  for (int i = 1; i <= n; ++i) pw2[i] = pw2[i - 1] * 2 % P;
  for (int i = 1; i <= m; ++i) {
    std::cin >> x >> y;
    if (y - x != 1 && y - x != k + 1) return std::cout << 0 << '\n', 0;
    if (y - x == k + 1) {
      edge[++cnt] = std::make_pair(x, y);
      if (edge[cnt].first < edge[1].first || edge[cnt].first >= edge[1].second)
        return std::cout << 0 << '\n', 0;
    }
  }
  if (k == 0 || k >= n - 1) return std::cout << 1 << '\n', 0;
  if (cnt) {
    for (int i = 1; i <= n; ++i) {
      int s = i, t = i + k + 1, dec = cnt;
      if (s > edge[1].second || t > n) break;
      if (!(s <= edge[1].first && edge[cnt].first < t)) continue;
      if (s == edge[1].first) dec--;
      down(t, n - k);
      add(ans, pw2[t - s - dec - 1]);
    }
    std::cout << ans << '\n';
  } else {
    ans = 1;
    for (int i = 1; i <= n; ++i) {
      if (i + k + 1 > n) break;
      add(ans, pw2[std::min(n - i - k - 1, k)]);
    }
    std::cout << ans << '\n';
  }
  return 0;
}
