#include <bits/stdc++.h>
using namespace std;
int n, m, K;
int s[1000005], p[1000005];
int main() {
  scanf("%d%d%d", &n, &m, &K);
  ++K;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x + K == y)
      s[x] = 1;
    else if (x + 1 != y)
      return puts("0"), 0;
    ;
  }
  for (int i = 1; i <= n; i++) s[i] += s[i - 1];
  for (int i = K; i <= n; i++)
    if (s[i] - s[i - 1] && s[i - K]) return puts("0"), 0;
  ;
  p[0] = 1;
  for (int i = 1; i <= n; i++) p[i] = p[i - 1] * 2 % 1000000007;
  int ans = (s[n] == 0);
  for (int i = 1; i <= n - K; i++)
    if (s[i] == s[n] && (i <= K || s[i - K] == 0))
      ans = (ans + p[min(i, K) - s[i - 1] - 1]) % 1000000007;
  printf("%d\n", ans);
}
