#include <bits/stdc++.h>
using namespace std;
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
int L[1000005];
int R[1000005];
int Top;
int H[1000005];
void Error() {
  puts("0");
  exit(0);
}
int N, M, K;
int S[1000005];
int Left, Right;
int F[1000005];
int G[1000005];
int Ans;
void Init() {
  Get(N);
  Get(M);
  Get(K);
  K++;
  for (int i = 1, U, V; i <= M; i++) {
    Get(U);
    Get(V);
    if (V - U == 1) continue;
    if (V - U != K) Error();
    Top++;
    L[Top] = U;
    R[Top] = V;
    H[U] = 1;
  }
  G[0] = 1;
  for (int i = 1; i <= N; i++) {
    (F[i] = F[i - 1] + F[i - 1] + 1) %= (1000000007);
    (G[i] = G[i - 1] + G[i - 1]) %= (1000000007);
  }
  if (N > K) {
    S[1] += 1;
    S[K + 1] += -1;
    S[N - K + 1] += -1;
    for (int i = 1; i <= N; i++) S[i] += S[i - 1];
    for (int i = 1; i <= N; i++) S[i] += S[i - 1];
  }
  Left = 1;
  Right = 0x2f2f2f2f;
  for (int i = 1; i <= Top; i++) {
    if (L[i] > Left) Left = L[i];
    if (R[i] - 1 < Right) Right = R[i] - 1;
  }
  if (Left > Right) Error();
  if (Right > N - K) Right = N - K;
  Ans = 1;
  for (int i = Left; i <= Right; i++) {
    if (H[i]) {
      int X = S[i] - Top;
      if (X < 0) continue;
      (Ans += F[X]) %= (1000000007);
    } else {
      int X = S[i] - Top - 1;
      if (X < 0) continue;
      (Ans += G[X]) %= (1000000007);
    }
  }
}
void Output() { printf("%d\n", Ans); }
int main() {
  Init();
  Output();
  return 0;
}
