func_code_string: #include <bits/stdc++.h>   using namespace std;   void RD(int &x) { scanf( %d , &x); }   void RD(long long &x) { scanf( %I64d , &x); }   void RD(unsigned int &x) { scanf( %u , &x); }   void RD(double &x) { scanf( %lf , &x); }   void RD(int &x, int &y) { scanf( %d%d , &x, &y); }   void RD(long long &x, long long &y) { scanf( %I64d%I64d , &x, &y); }   void RD(unsigned int &x, unsigned int &y) { scanf( %u%u , &x, &y); }   void RD(double &x, double &y) { scanf( %lf%lf , &x, &y); }   void RD(int &x, int &y, int &z) { scanf( %d%d%d , &x, &y, &z); }   void RD(long long &x, long long &y, long long &z) {     scanf( %I64d%I64d%I64d , &x, &y, &z);   }   void RD(unsigned int &x, unsigned int &y, unsigned int &z) {     scanf( %u%u%u , &x, &y, &z);   }   void RD(double &x, double &y, double &z) { scanf( %lf%lf%lf , &x, &y, &z); }   void RD(char &x) { x = getchar(); }   void RD(char *s) { scanf( %s , s); }   void RD(string &s) { cin >> s; }   void PR(int x) { printf( %d n , x); }   void PR(int x, int y) { printf( %d %d n , x, y); }   void PR(long long x) { printf( %I64d n , x); }   void PR(unsigned int x) { printf( %u n , x); }   void PR(unsigned long long x) { printf( %I64u n , x); }   void PR(double x) { printf( %.6lf n , x); }   void PR(char x) { printf( %c n , x); }   void PR(char *x) { printf( %s n , x); }   void PR(string x) { cout << x << endl; }   const int mod = 1000000007;   const long long inf = ((long long)1) << 60;   const int INF = 100000000;   const int N = 1000005;   vector<pair<int, int> > V;   long long Pow[N];   int n, m, K;   void init() {     Pow[0] = 1;     int i;     for (i = 1; i <= N - 1; i++) Pow[i] = Pow[i - 1] * 2 % mod;   }   int main() {     init();     while (scanf( %d , &n) != -1) {       RD(m, K);       V.clear();       int i, x, y, cnt, flag = 1;       for (i = 1; i <= m; i++) {         RD(x, y);         if (y - x != 1 && y - x != K + 1) flag = 0;         if (y - x == K + 1) V.push_back(make_pair(x, y));       }       if (!flag) {         puts( 0 );         continue;       }       sort(V.begin(), V.end());       if (!K || K >= n - 1) {         puts( 1 );         continue;       }       for (i = 0; i < V.size(); i++)         if (!(V[i].first >= V[0].first && V[i].first < V[0].second)) {           break;         }       if (i < V.size()) {         puts( 0 );         continue;       }       long long ans = 0;       if (!V.size()) ans++;       int t = V.size();       for (i = 1; i <= n; i++) {         x = i;         y = i + K + 1;         cnt = t;         if (y > n || t && x > V[0].first) break;         if (t && !(x <= V[0].first && V[t - 1].first < y)) continue;         if (t && x == V[0].first) cnt--;         y = ((y) < (n - K) ? (y) : (n - K));         ans += Pow[y - x - 1 - cnt];         ans %= mod;       }       PR(ans);     }     return 0;   }   