#include <bits/stdc++.h>
using namespace std;
int n, m, q;
const int N = 2200;
int a[N][N], sum[2][N][N];
void cp(int x, int y, bool f) {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) a[i + x][j + y] = a[i][j] ^ f;
}
int get(int x) {
  int res = 0;
  for (int i = 30; i >= 0; i--) {
    res ^= x >> i & 1;
  }
  return res;
}
long long calc(int x, int y) {
  long long segx = x / n, segy = y / m;
  x %= n;
  y %= m;
  long long res = 1LL * segx * segy * sum[0][n][m];
  int fx = get(segx), fy = get(segy);
  res += sum[fx][x][m] * segy + sum[fy][n][y] * segx + sum[fx ^ fy][x][y];
  return res;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%1d", &a[i][j]);
  cp(0, m, 1);
  cp(n, 0, 1);
  cp(n, m, 0);
  n *= 2;
  m *= 2;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      sum[0][i][j] =
          sum[0][i - 1][j] + sum[0][i][j - 1] - sum[0][i - 1][j - 1] + a[i][j];
      sum[1][i][j] = sum[1][i - 1][j] + sum[1][i][j - 1] -
                     sum[1][i - 1][j - 1] + (a[i][j] ^ 1);
    }
  assert(sum[0][n][m] == sum[1][n][m]);
  while (q--) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    long long ans = calc(x2, y2) - calc(x2, y1 - 1) - calc(x1 - 1, y2) +
                    calc(x1 - 1, y1 - 1);
    printf("%lld\n", ans);
  }
}
