#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long INF = 1e18;
const long long M = 1e9 + 7;
const long long maxn = 1005;
long long a[2][maxn][maxn], s[2][maxn][maxn];
char str[maxn];
long long n, m, q;
inline bool run(long long x, long long y) {
  return (__builtin_popcount(x) + __builtin_popcount(y)) & 1;
}
long long f(long long x, long long y) {
  if (x <= 0 || y <= 0) return 0;
  long long a = (x - 1) / n, b = (y - 1) / m;
  long long res = 0, tot = m * n;
  res = a * b / 2 * tot;
  long long p = x - a * n, q = y - b * m;
  if (!(a & 1) && !(b & 1)) {
    res += p * b / 2 * m + q * a / 2 * n;
  } else if (!(a & 1) && (b & 1)) {
    long long t = run(a, b - 1);
    res += q * a / 2 * n + p * (b - 1) / 2 * m;
    res += s[t][p][m];
  } else if ((a & 1) && !(b & 1)) {
    long long tt = run(a - 1, b);
    res += q * (a - 1) / 2 * n + p * b / 2 * m;
    res += s[tt][n][q];
  } else {
    long long t = run(a, b - 1), tt = run(a - 1, b);
    res += q * (a - 1) / 2 * n + p * (b - 1) / 2 * m;
    res += s[t][p][m] + s[tt][n][q] + s[run(a - 1, b - 1)][n][m];
  }
  long long z = run(a, b);
  res += s[z][p][q];
  return res;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  for (long long i = 1; i <= n; ++i) {
    cin >> (str + 1);
    for (long long j = 1; j <= m; ++j) {
      a[0][i][j] = str[j] - '0';
      a[1][i][j] = !a[0][i][j];
    }
  }
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= m; ++j) {
      for (long long k = 0; k < 2; ++k) {
        s[k][i][j] =
            s[k][i - 1][j] + s[k][i][j - 1] - s[k][i - 1][j - 1] + a[k][i][j];
      }
    }
  }
  while (q--) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << f(x1 - 1, y1 - 1) + f(x2, y2) - f(x1 - 1, y2) - f(x2, y1 - 1)
         << endl;
  }
  return 0;
}
