#include <bits/stdc++.h>
using namespace std;
int A[2001][2001], B[2001][2001], a[2002][2002], b[2002][2002];
int sa[2002][2002], sb[2002][2002];
long long n, m, q, t[33];
void init() {
  t[0] = 1;
  for (int i = 1; i <= 30; i++) t[i] = t[i - 1] * 2;
  memset(sa, 0, sizeof(sa));
  memset(sb, 0, sizeof(sb));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sa[i][j] = sa[i - 1][j] + sa[i][j - 1] - sa[i - 1][j - 1] + A[i][j];
      sb[i][j] = sb[i - 1][j] + sb[i][j - 1] - sb[i - 1][j - 1] + B[i][j];
    }
  }
}
int s = 0;
void judge(long long x) {
  for (int i = 30; i >= 0; i--) {
    if (t[i] < x) x -= t[i], s++;
  }
}
long long solve(long long x, long long y) {
  s = 0;
  long long ret = 0;
  if (x == 0 || y == 0) return 0;
  ret += (x * y - (x % (2 * n)) * (y % (2 * m))) / 2;
  long long xx = x - x % (2 * n) + 1;
  long long yy = y - y % (2 * m) + 1;
  long long tx = (xx - 1) / n + 1;
  long long ty = (yy - 1) / m + 1;
  judge(tx);
  judge(ty);
  long long dx = x - xx + 1, dy = y - yy + 1;
  if (s % 2 == 1) {
    if (dx <= n && dy <= m) ret += sb[dx][dy];
    if (dx <= n && dy > m) ret += sa[dx][dy - m] + sb[dx][m];
    if (dx > n && dy <= m) ret += sb[n][dy] + sa[dx - n][dy];
    if (dx > n && dy > m)
      ret += sb[n][m] + sa[n][dy - m] + sa[dx - n][m] + sb[dx - n][dy - m];
  } else {
    if (dx <= n && dy <= m) ret += sa[dx][dy];
    if (dx <= n && dy > m) ret += sb[dx][dy - m] + sa[dx][m];
    if (dx > n && dy <= m) ret += sa[n][dy] + sb[dx - n][dy];
    if (dx > n && dy > m)
      ret += sa[n][m] + sb[n][dy - m] + sb[dx - n][m] + sa[dx - n][dy - m];
  }
  return ret;
}
int main() {
  scanf("%lld%lld%lld", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    char str[1001];
    scanf("%s", str + 1);
    for (int j = 1; j <= m; j++) {
      A[i][j] = str[j] - '0';
      B[i][j] = (str[j] - '0') ^ 1;
    }
  }
  init();
  while (q--) {
    long long x1, y1, x2, y2;
    scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2);
    long long ans = solve(x2, y2) - solve(x1 - 1, y2) - solve(x2, y1 - 1) +
                    solve(x1 - 1, y1 - 1);
    printf("%lld\n", ans);
  }
}
