#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
inline int in() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x;
}
long long n, m, q;
char ch[MAXN];
long long a[1010][1010], sum[1010][1010];
long long size(long long x, long long y) {
  int k = 0;
  while (x > (n << k) || y > (m << k)) ++k;
  return k;
}
long long solve(long long x, long long y, long long k, long long N, long long M,
                bool flag) {
  if (k == 0) {
    if (flag == false)
      return sum[x][y];
    else
      return x * y - sum[x][y];
  }
  if (x == N || y == M) return x * y / 2;
  long long mx = N >> 1, my = M >> 1;
  if (x <= mx && y <= my)
    return solve(x, y, k - 1, mx, my, flag);
  else if (x > mx && y <= my)
    return solve(mx, y, k - 1, mx, my, flag) +
           solve(x - mx, y, k - 1, mx, my, flag ^ 1);
  else if (x <= mx && y > my)
    return solve(x, my, k - 1, mx, my, flag) +
           solve(x, y - my, k - 1, mx, my, flag ^ 1);
  else if (x > mx && y > my)
    return solve(mx, my, k - 1, mx, my, flag) +
           solve(x - mx, my, k - 1, mx, my, flag ^ 1) +
           solve(mx, y - my, k - 1, mx, my, flag ^ 1) +
           solve(x - mx, y - my, k - 1, mx, my, flag);
}
int main() {
  n = in();
  m = in();
  q = in();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", ch + 1);
    for (int j = 1; j <= m; ++j)
      a[i][j] = ch[j] - '0', sum[i][j] = sum[i][j - 1] + a[i][j];
    for (int j = 1; j <= m; ++j) sum[i][j] += sum[i - 1][j];
  }
  while (q--) {
    int x1 = in(), y1 = in(), x2 = in(), y2 = in();
    long long k = size(x2, y2), N = n << k, M = m << k;
    printf("%lld\n", solve(x2, y2, k, N, M, false) -
                         solve(x1 - 1, y2, k, N, M, false) -
                         solve(x2, y1 - 1, k, N, M, false) +
                         solve(x1 - 1, y1 - 1, k, N, M, false));
  }
  return 0;
}
