#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
char s[2005][2005];
long long sum[2005][2005];
bool cnt(long long x) {
  int ret = 0;
  while (x > 0) {
    if (x & 1) ret++;
    x >>= 1;
  }
  return (ret & 1);
}
long long f(long long a, long long b, bool inv) {
  if (!a || !b) return 0;
  if (a <= n && b <= m) {
    if (inv)
      return a * b - sum[a][b];
    else
      return sum[a][b];
  }
  if (a <= n) {
    if (b <= 2 * m) return f(a, m, inv) + f(a, b - m, !inv);
    long long M = 2 * m;
    long long t = a * m;
    while (2 * M <= b) M <<= 1, t <<= 1;
    return t + f(a, b - M, !inv);
  } else {
    if (a <= 2 * n) return f(n, b, inv) + f(a - n, b, !inv);
    long long N = 2 * n;
    long long t = b * n;
    while (2 * N <= a) N <<= 1, t <<= 1;
    return t + f(a - N, b, !inv);
  }
}
void solve() {
  cin >> n >> m >> q;
  for (long long i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      sum[i + 1][j + 1] =
          -sum[i][j] + sum[i][j + 1] + sum[i + 1][j] + (s[i][j] == '1');
    }
  }
  while (q--) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << f(x2, y2, false) - f(x1 - 1, y2, false) - f(x2, y1 - 1, false) +
                f(x1 - 1, y1 - 1, false)
         << endl;
  }
}
int main(void) {
  long long t;
  t = 1;
  while (t--) solve();
  return 0;
}
