#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1e8;
const long long mod = 1000000007;
long long expMod(long long base, long long exponente) {
  long long res = 1;
  while (exponente > 0) {
    if ((exponente & 1) != 0) {
      res *= base;
      res %= mod;
    }
    base *= base;
    base %= mod;
    exponente >>= 1;
  }
  return res;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  long long lo = 100000000;
  long long hi = -1;
  long long puentes = 0;
  for (int i = 0; i < (int)m; i++) {
    long long u, v;
    cin >> u >> v;
    if (v - u == 1)
      continue;
    else if (v - u != (k + 1)) {
      cout << 0 << endl;
      return 0;
    } else {
      lo = min(lo, u);
      hi = max(hi, v);
      puentes++;
    }
  }
  if (hi == -1) {
    long long res = 1;
    for (long long start = 1; start <= n - k - 1; start++) {
      long long posiPuentes = min(n - k - 1 - start, k);
      res += expMod(2, posiPuentes);
      res %= mod;
    }
    cout << res << endl;
    return 0;
  } else if (hi - lo >= 2 * (k + 1)) {
    cout << 0 << endl;
    return 0;
  } else {
    long long res = 0;
    for (int start = 1; start <= lo; start++) {
      if (hi - start >= 2 * (k + 1))
        continue;
      else {
        long long posiPuentes = min(n - (start + k + 1) + 1, k + 1);
        if (start < lo)
          res += expMod(2, posiPuentes - puentes - 1);
        else
          res += expMod(2, posiPuentes - puentes);
        res %= mod;
      }
    }
    cout << res << endl;
    return 0;
  }
  return 0;
}
