#include <bits/stdc++.h>
using namespace std;
int st[1000010];
int mod = 1000000007;
vector<vector<int> > g;
int dp[1000010][2];
int n, m, k;
int a[1000010];
int main() {
  st[0] = 1;
  for (int i = (1); i < (1000010); ++i) {
    st[i] = st[i - 1] + st[i - 1];
    if (st[i] >= mod) st[i] -= mod;
  }
  scanf("%d%d%d", &n, &m, &k);
  int max1 = -1;
  int min1 = 2000000000;
  int tot = 0;
  for (int i = (0); i < (m); ++i) {
    int v1, v2;
    scanf("%d%d", &v1, &v2);
    v1--;
    v2--;
    if (((v2 - v1) != 1) && (v2 - v1 != k + 1)) {
      cout << 0 << endl;
      return 0;
    }
    if (v2 - v1 == k + 1) {
      a[v1] = 1;
      max1 = v1;
      min1 = ((min1 < v1) ? (min1) : (v1));
      tot++;
    }
  }
  if (max1 - min1 > k) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = (1); i < (n); ++i) a[i] += a[i - 1];
  int res = 1;
  for (int i = (0); i < (n); ++i) {
    int v = i + k + 1;
    if (v >= n) break;
    if (i + k + 1 <= max1) continue;
    if (i > min1) break;
    int last = min(i + k, n - k - 2);
    int sum = a[last] - a[i];
    int c = a[i];
    if (i) c -= a[i - 1];
    if (c) res--;
    if (res < 0) res += mod;
    res += st[last - i - sum];
    if (res >= mod) res -= mod;
  }
  cout << res << endl;
  return 0;
}
