func_code_string: #include <bits/stdc++.h>   using namespace std;   long long fact[200001], inv_fact[200001], dp[2010][26];   bool cmp(pair<int, int> a, pair<int, int> b) {     return a.first + a.second < b.first + b.second;   }   long long ModExp(int a, int n) {     long long x = a % 1000000007, y = 1 % 1000000007;     while (n > 0) {       if (n % 2) y = (y * x) % 1000000007;       x = (x * x) % 1000000007;       n /= 2;     }     return y;   }   long long ModInverse(int a) { return ModExp(a, 1000000007 - 2); }   void PreCompute() {     fact[0] = inv_fact[0] = 1;     for (int i = 1; i < 200001; i++) {       fact[i] = (i * fact[i - 1]) % 1000000007;       inv_fact[i] = (ModInverse(i) * inv_fact[i - 1]) % 1000000007;     }   }   long long nCr(int n, int r) {     if (n < 0 || r < 0 || n < r)       return 0;     else       return (fact[n] * ((inv_fact[r] * inv_fact[n - r]) % 1000000007)) %              1000000007;   }   long long NumPaths(pair<int, int> a, pair<int, int> b) {     return nCr((b.first - a.first) + (b.second - a.second), (b.first - a.first));   }   int main() {     int n, m, k, p, i, j, x, y, z;     long long P, Q, ans;     set<pair<int, int> > s;     vector<pair<int, int> > v;     scanf( %d%d%d%d , &n, &m, &k, &p);     for (x = 1; x <= k; x++) {       scanf( %d%d , &i, &j);       s.insert(make_pair(i, j));     }     s.insert(make_pair(1, 1));     if (s.size() == k) p = (p - 1) / 2 + 1;     for (x = p, k = 0; x > 1; k++, x = (x - 1) / 2 + 1)       ;     v.push_back(make_pair(0, 0));     for (auto it = s.begin(); it != s.end(); it++) v.push_back(*it);     PreCompute();     for (i = v.size() - 1; i > 0; i--) {       long long sum = 0;       for (j = 0; j < k; j++) {         dp[i][j] = NumPaths(v[i], make_pair(n, m));         for (x = i + 1; x < v.size(); x++)           dp[i][j] = (dp[i][j] + (1000000007 - (NumPaths(v[i], v[x]) * dp[x][j]) %                                                    1000000007)) %                      1000000007;         dp[i][j] = (dp[i][j] + (1000000007 - sum)) % 1000000007;         sum = (sum + dp[i][j]) % 1000000007;       }     }     long long sum = 0;     for (i = 1, j = 0, P = 0; j < k; j++, p = (p - 1) / 2 + 1) {       P = (P + dp[i][j] * p) % 1000000007;       sum = (sum + dp[i][j]) % 1000000007;     }     Q = NumPaths(make_pair(1, 1), make_pair(n, m));     sum = (Q + 1000000007 - sum) % 1000000007;     P = (P + sum) % 1000000007;     ans = (P * ModInverse((int)Q)) % 1000000007;     printf( %lld n , ans);     return 0;   }   