#include <bits/stdc++.h>
using namespace std;
const long long N = 1005;
long long n, m, q;
char mp[N][N];
long long sum[2][N][N];
void init() {
  scanf("%lld%lld%lld", &n, &m, &q);
  for (long long i = 1; i <= n; ++i) {
    scanf("%s", mp[i] + 1);
    for (long long j = 1; j <= m; ++j) {
      sum[0][i][j] = sum[0][i][j - 1] + mp[i][j] - '0';
      sum[1][i][j] = sum[1][i][j - 1] + ((mp[i][j] - '0') ^ 1);
    }
  }
  for (long long i = 1; i <= m; ++i) {
    for (long long j = 1; j <= n; ++j) {
      sum[0][j][i] += sum[0][j - 1][i];
      sum[1][j][i] += sum[1][j - 1][i];
    }
  }
}
long long count(long long n) {
  long long tmp = 0;
  while (n) {
    if (n % 2) ++tmp;
    n /= 2;
  }
  return tmp;
}
long long pos(long long x, long long y) { return count(x ^ y) & 1; }
long long get(long long x, long long y) {
  long long u = x / n, v = y / m, tot = 0, p = x % n, q = y % m;
  long long rightdown = pos(u, v), right = pos(u - 1, v), down = pos(u, v - 1),
            now = pos(u - 1, v - 1);
  if (u % 2 == 0 && v % 2 == 0) {
    tot += u * v / 2 * n * m;
    tot += u / 2 * n * q;
    tot += v / 2 * m * p;
    tot += sum[rightdown][p][q];
  } else if (u % 2 == 1 && v % 2 == 0) {
    tot += u * v / 2 * n * m;
    tot += (u - 1) / 2 * n * q + sum[right][n][q];
    tot += v / 2 * m * p;
    tot += sum[rightdown][p][q];
  } else if (u % 2 == 0 && v % 2 == 1) {
    tot += u * v / 2 * n * m;
    tot += u / 2 * n * q;
    tot += (v - 1) / 2 * m * p + sum[down][p][m];
    tot += sum[rightdown][p][q];
  } else {
    tot += (u * v - 1) / 2 * n * m + sum[now][n][m];
    tot += (u - 1) / 2 * n * q + sum[right][n][q];
    tot += (v - 1) / 2 * m * p + sum[down][p][m];
    tot += sum[rightdown][p][q];
  }
  return tot;
}
void solve() {
  while (q--) {
    long long x1, x2, y1, y2;
    scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
    printf("%lld\n", get(x2, y2) - get(x1 - 1, y2) - get(x2, y1 - 1) +
                         get(x1 - 1, y1 - 1));
  }
}
int main() {
  init();
  solve();
  return 0;
}
