#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  int l = -1, r = -1;
  int one = 0;
  int die = 0;
  vector<int> can(n + 1, 1);
  int mx = -1;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    if (u + 1 == v)
      one += 1;
    else if (v - u != k + 1)
      die = 1;
    if (v - u == k + 1) {
      if (l == -1) {
        l = u, r = v;
      } else {
        if (r <= u)
          die = 1;
        else
          can[u] = 0, mx = max(mx, u);
      }
    }
  }
  if (die) {
    cout << 0 << '\n';
    return (0);
  }
  long long ans = 1;
  const long long mod = 1e9 + 7;
  vector<long long> p2(n + 1);
  p2[0] = 1;
  for (int i = 1; i <= n; i++) p2[i] = (2LL * p2[i - 1]) % mod;
  if (l != -1) {
    ans = 0;
    long long ways = 1;
    vector<int> acc_in(n + 1, 0);
    vector<int> acc_out(n + 1, 0);
    for (int u = l + 1; u < r; u++) {
      if (not can[u]) continue;
      long long add = 1;
      if (1 <= u - k - 1 and mx < u) acc_in[u] = 1;
      if (u + k + 1 <= n) acc_out[u] = 1;
    }
    for (int i = l; i <= r; i++) acc_out[i] += acc_out[i - 1];
    for (int i = r - 1; i >= l; i--) acc_in[i] += acc_in[i + 1];
    for (int u = l + 1; u < r; u++) {
      if (not can[u]) continue;
      if (u + k + 1 <= n) {
        long long add = p2[acc_out[u - 1]] * p2[acc_in[u + 1]];
        add %= mod;
        ans += add;
        if (ans >= mod) ans -= mod;
      }
    }
    if (acc_in[l])
      ans += p2[acc_in[l]];
    else
      ans += 1;
    if (ans >= mod) ans -= mod;
  } else {
    for (int r = 1 + k + 1; r <= n; r++) {
      int l = r - k - 1;
      l = max(l, k + 1);
      long long add = max(0, r - l - 1);
      ans += p2[add];
      if (ans >= mod) ans -= mod;
    }
  }
  cout << ans << '\n';
  return (0);
}
