#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 7, Mod = 1000000000 + 7;
int n, m, l, A[N], tot, Cnt;
bool Book[N];
queue<int> Q;
inline int KSM(int x, int p) {
  int Ret = 1;
  while (p) {
    if (p & 1) Ret = 1ll * Ret * x % Mod;
    x = 1ll * x * x % Mod, p >>= 1;
  }
  return Ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &l);
  int u, v;
  for (int i = (1), iLimit = (m); i <= iLimit; (++(i))) {
    scanf("%d%d", &u, &v);
    if (v == u + 1) continue;
    if (v != u + l + 1) return puts("0"), 0;
    (++(tot)), Book[u] = 1;
  }
  long long Ans = 0;
  for (int i = (1), iLimit = (n - l - 1); i <= iLimit; (++(i))) {
    while (!Q.empty() && Q.front() <= i - l - 1) {
      if (Book[Q.front()]) return cout << Ans + (bool)(!tot), 0;
      Q.pop();
    }
    if (Book[i]) (++(Cnt));
    Q.push(i);
    if (Cnt == tot) {
      if (Book[i])
        Ans += KSM(2, Q.size() - tot), Ans %= Mod;
      else
        Ans += KSM(2, Q.size() - tot - 1), Ans %= Mod;
    }
  }
  cout << (Ans + (bool)(!tot)) % Mod;
  return 0;
}
