func_code_string: #include <bits/stdc++.h>   using namespace std;   long long int dp[2002][2002];   vector<long long int> col, row;   long long int sol(long int p, long int q, int n, int m, int jk) {     if (p == 0 || q == 0) {       return 0;     }     vector<long long int>::iterator it;     if (p <= 2 * n && q <= 2 * m) {       if (jk == 0) {         return (p * q - dp[p][q]);       }       return dp[p][q];     } else if (p <= 2 * n) {       it = lower_bound(col.begin(), col.end(), q);       if (*it != q) {         it--;       }       long long int ab = *it;       q = q % ab;       ab /= 2;       ab = ab * p;       return ab + sol(p, q, n, m, 1 - jk);     } else {       it = lower_bound(row.begin(), row.end(), p);       if (*it != p) {         it--;       }       long long int ab = *it;       p = p % ab;       ab /= 2;       ab = ab * q;       return ab + sol(p, q, n, m, 1 - jk);     }     return 0;   }   int main() {     int n, m, q;     cin >> n >> m >> q;     int arr[2 * n + 2][2 * m + 2];     for (int x = 1; x <= n; x++) {       string s;       cin >> s;       for (int y = 1; y <= m; y++) {         arr[x][y] = s[y - 1] -  0 ;       }     }     for (int x = 1; x <= 2 * n; x++) {       for (int y = 1; y <= 2 * m; y++) {         if (x <= n && y <= m) {         } else if (x > n && y > m) {           arr[x][y] = arr[x - n][y - m];         } else if (x > n) {           arr[x][y] = 1 - arr[x - n][y];         } else {           arr[x][y] = 1 - arr[x][y - m];         }         dp[x][y] = dp[x][y - 1] + dp[x - 1][y] - dp[x - 1][y - 1] + arr[x][y];       }     }     int sz = 0;     col.push_back(m);     while (col[sz] < INT_MAX) {       col.push_back(col[sz++] * 2);     }     sz = 0;     row.push_back(n);     while (row[sz] < INT_MAX) {       row.push_back(row[sz++] * 2);     }     while (q--) {       int x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       long long int a = sol(x2, y2, n, m, 1);       long long int b = sol(x1 - 1, y2, n, m, 1);       long long int c = sol(x2, y1 - 1, n, m, 1);       long long int d = sol(x1 - 1, y1 - 1, n, m, 1);       cout << a + d - b - c << endl;     }   }   