#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 5;
const int mod = 1000000007;
int n, m, k, l, r, cnt, ans, two[N] = {1};
bool f[N];
int main(int argc, char **argv) {
  int x, y;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) two[i] = (two[i - 1] << 1) % mod;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    if (y == x + 1) continue;
    if (y - x != k + 1) {
      puts("0");
      return 0;
    }
    if (!l) l = x;
    f[r = x] = 1;
    ++cnt;
  }
  if (l + k < r) {
    puts("0");
    return 0;
  }
  if (cnt) {
    for (int i = max(1, r - k), t; i <= l; ++i) {
      t = min(i + k, n - k - 1) - i - cnt + f[i];
      if (t < 0) continue;
      ans = (ans + two[t]) % mod;
    }
  } else {
    ans = 1;
    for (int i = 1, t; i <= n; ++i) {
      t = min(i + k, n - k - 1) - i - cnt + f[i];
      if (t < 0) continue;
      ans = (ans + two[t]) % mod;
    }
  }
  printf("%d\n", ans);
  return 0;
}
