#include <bits/stdc++.h>
const int MAXN = 2011, MAXM = 2011;
int Bc[1 << 15];
int N, M, Qc;
int Map[MAXN][MAXM];
int Sum[MAXN][MAXM];
char input[MAXM];
long long Tmp;
int Bcnt(int a) { return Bc[a & 32767] + Bc[a >> 15]; }
inline int Id(const int &p, const int &l) { return (p - 1) / l + 1; }
inline int Up(const int &p, const int &l) { return Id(p, l) * l; }
inline int Dw(const int &p, const int &l) { return ((p - 1) / l) * l + 1; }
inline int Norm(const int &p, const int &l) { return ((p - 1) % l) + 1; }
inline int Sum_(const int &xl, const int &xr, const int &yl, const int &yr) {
  return Sum[xr][yr] - Sum[xl - 1][yr] - Sum[xr][yl - 1] + Sum[xl - 1][yl - 1];
}
long long Cal(int xl, int xr, int yl, int yr) {
  int dx = Id(xr, N << 1) - Id(xl, N << 1);
  if (dx >= 1)
    return Cal(xl, Up(xl, N << 1), yl, yr) + Cal(Dw(xr, N << 1), xr, yl, yr);
  int dy = Id(yr, M << 1) - Id(yl, M << 1);
  if (dy >= 1)
    return Cal(xl, xr, yl, Up(yl, M << 1)) + Cal(xl, xr, Dw(yr, M << 1), yr);
  long long ret = ((Bcnt(Id(xl, N << 1) - 1) + Bcnt(Id(yl, M << 1) - 1)) & 1)
                      ? (-1LL)
                      : 1LL;
  xl = Norm(xl, N << 1);
  xr = Norm(xr, N << 1);
  yl = Norm(yl, M << 1);
  yr = Norm(yr, M << 1);
  ret *= (long long)Sum_(xl, xr, yl, yr);
  return ret;
}
int main() {
  for (int i = 1; i < (1 << 15); ++i) Bc[i] = Bc[i >> 1] + (i & 1);
  scanf("%d%d%d", &N, &M, &Qc);
  for (int i = 1; i <= N; ++i) {
    scanf("%s", input);
    for (int j = 1; j <= M; ++j) {
      Map[i][j] = input[j - 1] - '0';
      if (Map[i][j] == 0) Map[i][j] = -1;
    }
  }
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) Map[i][j + M] = -Map[i][j];
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= (M << 1); ++j) Map[i + N][j] = -Map[i][j];
  for (int i = 1; i <= (N << 1); ++i)
    for (int j = 1; j <= (M << 1); ++j)
      Sum[i][j] = Sum[i - 1][j] + Sum[i][j - 1] - Sum[i - 1][j - 1] + Map[i][j];
  for (int i = 1, xl, yl, xr, yr; i <= Qc; ++i) {
    scanf("%d%d%d%d", &xl, &yl, &xr, &yr);
    Tmp = 1LL * (yr - yl + 1) * (xr - xl + 1);
    printf("%I64d\n", (Tmp + Cal(xl, xr, yl, yr)) >> 1);
  }
  return 0;
}
