#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const int maxn = 100005;
const int mod = 1000000007;
int eu[maxn], ev[maxn], n, m, k;
bool vis[maxn * 10];
int sum[maxn * 10];
long long sy[maxn * 10];
int main() {
  sy[0] = 1;
  for (int i = 1; i < maxn * 10; i++) {
    sy[i] = sy[i - 1] * 2;
    sy[i] %= mod;
  }
  scanf("%d%d%d", &n, &m, &k);
  bool sign = 0;
  int s, t = 0, far = -1;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    eu[i] = u, ev[i] = v;
    int tmp = v - u;
    if (tmp == 1) continue;
    if (tmp == k + 1) {
      vis[u] = vis[v] = 1;
      sum[u] = 1;
      far = ((far) > (u) ? (far) : (u));
      if (t == 0)
        t = v, s = u;
      else if (t > 0) {
        if (t <= u) t = -1;
      }
      continue;
    }
    sign = 1;
  }
  if (sign || t == -1)
    printf("0\n");
  else {
    long long ans = 0;
    if (k >= n - 1)
      printf("1\n");
    else {
      if (t == 0) {
        ans++;
        for (int i = 1; i + k + 1 <= n; i++) {
          int r = ((i + k) < (n - k - 1) ? (i + k) : (n - k - 1));
          ans += sy[r - i];
          ans %= mod;
        }
      } else {
        for (int i = 1; i <= n; i++) sum[i] += sum[i - 1];
        ans++;
        for (int i = 1; i + k + 1 <= n && i <= s; i++) {
          if (i + k + 1 <= far) continue;
          int r = ((i + k) < (n - k - 1) ? (i + k) : (n - k - 1));
          int cnt = r - i - (sum[r] - sum[i]);
          if (cnt == 0 && vis[i]) continue;
          if (vis[i]) ans = (ans - 1 + mod) % mod;
          ans += sy[cnt];
          ans %= mod;
        }
      }
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
