#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
char grid[1005][1005];
int pre[1005][1005];
int get_bit_cnt(long long x) {
  int ret = 0;
  for (; x > 0; x -= x & -x) ret++;
  return ret;
}
bool isFlipped(long long a, long long b) {
  return (get_bit_cnt(a - 1) + get_bit_cnt(b - 1)) % 2;
}
long long go(long long x, long long y) {
  if (x < 1 || y < 1) return 0;
  long long a = (x - 1) / N + 1, b = (y - 1) / M + 1;
  long long resa = (x - 1) % N + 1, resb = (y - 1) % M + 1;
  long long numComplete = (a - 1) * (b - 1);
  long long ret = numComplete / 2 * N * M;
  if (numComplete % 2 == 1) {
    if (isFlipped(a - 1, b - 1))
      ret += N * M - pre[N][M];
    else
      ret += pre[N][M];
  }
  ret += (a - 1) / 2 * resb * N;
  if ((a - 1) % 2 == 1) {
    if (isFlipped(a - 1, b))
      ret += N * resb - pre[N][resb];
    else
      ret += pre[N][resb];
  }
  ret += (b - 1) / 2 * resa * M;
  if ((b - 1) % 2 == 1) {
    if (isFlipped(a, b - 1))
      ret += resa * M - pre[resa][M];
    else
      ret += pre[resa][M];
  }
  if (isFlipped(a, b))
    ret += resa * resb - pre[resa][resb];
  else
    ret += pre[resa][resb];
  return ret;
}
long long query(long long x1, long long y1, long long x2, long long y2) {
  return go(x2, y2) - go(x1 - 1, y2) - go(x2, y1 - 1) + go(x1 - 1, y1 - 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> M >> Q;
  for (int i = 0; i < N; i++) cin >> grid[i];
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= M; j++)
      pre[i][j] = pre[i][j - 1] + pre[i - 1][j] - pre[i - 1][j - 1] +
                  (grid[i - 1][j - 1] == '1');
  for (int i = 0, x1, y1, x2, y2; i < Q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << query(x1, y1, x2, y2) << "\n";
  }
  return 0;
}
