#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> L;
int P[1000005];
int sol(int i, int j) {
  int ans = 0;
  for (int p = (i); p < (j + 1); p++) {
    int cnt =
        min(n - k, p + k) - p - L.size() - ((L.size() and L[0] == p) ? 0 : 1);
    ans += P[cnt];
    ans = ans % 1000000007;
  }
  return ans;
}
int main() {
  int m, u, v;
  cin >> n >> m >> k;
  k++;
  int pos = 1;
  for (int i = (0); i < (m); i++) {
    scanf("%d %d", &u, &v);
    if (v - u != 1) {
      if (v - u == k) {
        L.push_back(u - 1);
      } else
        pos = 0;
    }
  }
  if (pos == 0) {
    cout << "0" << endl;
    return 0;
  }
  sort((L).begin(), (L).end());
  P[0] = 1;
  for (int i = (0); i < (1000000); i++) P[i + 1] = (2 * P[i]) % 1000000007;
  if (L.size() == 0) {
    cout << (sol(0, n - k - 1) + 1) % 1000000007 << endl;
    return 0;
  } else {
    int fin = L[0];
    int ini = max(0, L[L.size() - 1] - (k - 1));
    cout << sol(ini, fin) << endl;
  }
  return 0;
}
