#include <bits/stdc++.h>
using namespace std;
static const int MOD = 1000000007;
int64_t modpow(int64_t a, int n) {
  int64_t res = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) {
      res = res * a % MOD;
    }
    a = a * a % MOD;
  }
  return res;
}
int calc(const vector<vector<int> > &edges, int k) {
  int maxLeft = -1, minRight = edges.size();
  int n = edges.size();
  int cnt = 0;
  vector<bool> lefts(n);
  int res = 1;
  for (int l = 0; l < n; l++) {
    for (int r : edges[l]) {
      if (r - l == k + 1) {
        lefts[l] = true;
        maxLeft = max(maxLeft, l);
        minRight = min(minRight, r);
        cnt++;
        if (minRight <= maxLeft) return 0;
        continue;
      }
      if (r - l == 1) {
        continue;
      }
      return 0;
    }
  }
  vector<int> nums(n + 1);
  nums[max(0, maxLeft - k)] = -1;
  int numLefts = k;
  for (int i = max(0, maxLeft - k); i < min(n - k - 1, minRight); i++) {
    if (lefts[i]) {
      nums[i + 1] = nums[i];
      numLefts--;
    } else {
      nums[i + 1] = min(numLefts, nums[i] + 1);
    }
  }
  if (maxLeft != -1) {
    for (int i = max(0, maxLeft - k); i < min(n - k - 1, minRight); i++) {
      if (lefts[i]) continue;
      res = (res + modpow(2, nums[i + 1])) % MOD;
    }
    return res;
  }
  for (int i = 0; i < min(n - k - 1, k); i++) {
    res = (res + modpow(2, i)) % MOD;
  }
  if (n - k * 2 - 1 > 0)
    res = (res + modpow(2, k) * (n - k * 2 - 1) % MOD) % MOD;
  return res;
}
void solve(istream &in, ostream &out) {
  int n, m, k;
  in >> n >> m >> k;
  vector<vector<int> > edges(n);
  for (int i = 0; i < m; ++i) {
    int u, v;
    in >> u >> v;
    edges[u - 1].push_back(v - 1);
  }
  out << calc(edges, k) << endl;
}
int main() {
  solve(cin, cout);
  return 0;
}
