#include <bits/stdc++.h>
using namespace std;
const int SIZEN = 1000 + 10;
int a[SIZEN][SIZEN];
int N, M, Q;
long long P2[61];
void Init() {
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      a[i][j] += a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1];
    }
  }
  P2[0] = 1;
  for (int i = 1; i <= 60; i++) {
    P2[i] = P2[i - 1] * 2LL;
  }
}
bool get(int x) {
  int ret = 0;
  for (int i = 40; i >= 0 && x != 1; i--) {
    if (x > P2[i]) {
      x -= P2[i];
      ret++;
    }
  }
  if (ret & 1) return 1;
  return 0;
}
long long get(int x, int y) {
  if (x == 0 || y == 0) return 0;
  long long totx = x / (2 * N), toty = y / (M);
  long long OneLine = 1LL * N * M * toty + 1LL * N * (y - toty * M);
  long long ret = totx * OneLine;
  toty = y / (2 * M);
  totx = x - totx * (2 * N);
  ret += totx * toty * M;
  long long xx = x - (x / (2 * N)) * (2 * N), yy = y - (y / (2 * M)) * (2 * M);
  if (xx == 0 || yy == 0) return ret;
  bool flag = 0;
  flag = get(2 * (x / (2 * N)) + 1) ^ get(2 * (y / (2 * M)) + 1);
  long long tmpret = 0;
  if (xx >= N && yy >= M) {
    tmpret = a[N][M] + a[xx - N][yy - M] + (xx - N) * M - a[xx - N][M] +
             N * (yy - M) - a[N][yy - M];
  } else if (xx >= N && yy < M) {
    tmpret = a[N][yy] + yy * (xx - N) - a[xx - N][yy];
  } else if (xx < N && yy >= M) {
    tmpret = a[xx][M] + xx * (yy - M) - a[xx][yy - M];
  } else
    tmpret = a[xx][yy];
  if (flag) tmpret = xx * yy - tmpret;
  return ret + tmpret;
}
void solve(int lx, int ly, int rx, int ry) {
  long long ans =
      get(rx, ry) - get(rx, ly - 1) - get(lx - 1, ry) + get(lx - 1, ly - 1);
  printf("%lld\n", ans);
}
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]);
  }
  Init();
  while (Q--) {
    int lx, ly, rx, ry;
    scanf("%d%d%d%d", &lx, &ly, &rx, &ry);
    solve(lx, ly, rx, ry);
  }
  return 0;
}
