#include <bits/stdc++.h>
using namespace std;
char a[1010][1010];
int b[2020][2020];
int nn, mm;
long long fuck(long long x, long long y) {
  long long xx = x % nn;
  long long yy = y % mm;
  long long xxx;
  long long yyy;
  long long ans = x * y - xx * yy;
  ans >>= 1;
  if (xx == 0 || yy == 0)
    return ans;
  else {
    xxx = x / nn;
    yyy = y / mm;
    int flag = 0;
    if (xxx != 0) {
      while (xxx) {
        flag += (xxx & 1);
        xxx >>= 1;
      }
    }
    if (yyy != 0) {
      while (yyy) {
        flag += (yyy & 1);
        yyy >>= 1;
      }
    }
    int tmp = b[xx][yy];
    if (flag & 1) tmp = xx * yy - tmp;
    ans += tmp;
    return ans;
  }
}
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) b[i + n][j + m] = b[i][j] = a[i][j] - '0';
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      b[i + n][j] = b[i][j + m] = a[i][j] == '0' ? 1 : 0;
  for (int i = 1; i <= 2 * n; i++) {
    for (int j = 1; j <= 2 * m; j++) b[i][j] += b[i][j - 1];
    for (int j = 1; j <= 2 * m; j++) b[i][j] += b[i - 1][j];
  }
  nn = n * 2;
  mm = m * 2;
  while (q--) {
    int x, y, xx, yy;
    scanf("%d%d%d%d", &x, &y, &xx, &yy);
    printf("%lld\n", fuck(xx, yy) + fuck(x - 1, y - 1) - fuck(x - 1, yy) -
                         fuck(xx, y - 1));
  }
  return 0;
}
