#include <bits/stdc++.h>
using namespace std;
template <typename T>
T Abs(T first) {
  return (first < 0 ? -first : first);
}
template <typename T>
T Sqr(T first) {
  return (first * first);
}
string plural(string s) {
  return (int((s).size()) && s[int((s).size()) - 1] == 'x' ? s + "en"
                                                           : s + "s");
}
const int INF = (int)1e9;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
bool Read(int &first) {
  char c, r = 0, n = 0;
  first = 0;
  for (;;) {
    c = getchar();
    if ((c < 0) && (!r)) return (0);
    if ((c == '-') && (!r))
      n = 1;
    else if ((c >= '0') && (c <= '9'))
      first = first * 10 + c - '0', r = 1;
    else if (r)
      break;
  }
  if (n) first = -first;
  return (1);
}
int main() {
  if (0) freopen("in.txt", "r", stdin);
  int N, M, Q;
  int i, j, second, first, i2, j2, d, d2, y2, x2, m;
  int a1, a2, a3, a4;
  char s[45];
  int G[41][41], sum[41][41] = {0}, sum2[41][41] = {0};
  static int dyn[41][41][41][41];
  Read(N), Read(M), Read(Q);
  for (i = 1; i <= N; i++) {
    scanf("%s", &s);
    for (j = 1; j <= M; j++) {
      G[i][j] = s[j - 1] - '0';
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + G[i][j];
    }
  }
  for (d2 = 0; d2 < N; d2++)
    for (i = 1; i <= N; i++) {
      i2 = i + d2;
      if (i2 > N) break;
      for (d = 0; d < M; d++)
        for (j = 1; j <= M; j++) {
          j2 = j + d;
          if (j2 > M) break;
          if ((i == 4) && (i2 == 4) && (j == 5) && (j2 == 5)) i = i;
          dyn[i][j][i2][j2] += (sum[i2][j2] - sum[i2][j - 1] - sum[i - 1][j2] +
                                            sum[i - 1][j - 1] ==
                                        0
                                    ? 1
                                    : 0);
          for (a1 = 0; a1 < 2; a1++)
            for (a2 = 0; a2 < 2; a2++)
              for (a3 = 0; a3 < 2; a3++)
                for (a4 = 0; a4 < 2; a4++) {
                  if (a1 + a2 + a3 + a4 == 0) continue;
                  second = i + a1;
                  y2 = i2 - a2;
                  first = j + a3;
                  x2 = j2 - a4;
                  if ((y2 < second) || (x2 < first)) continue;
                  if (a1 + a2 + a3 + a4 == 1) m = 1;
                  if (a1 + a2 + a3 + a4 == 2) m = -1;
                  if (a1 + a2 + a3 + a4 == 3) m = 1;
                  if (a1 + a2 + a3 + a4 == 4) m = -1;
                  if ((i == 1) && (j == 1) && (i2 == 2) && (j2 == 2)) i = i;
                  dyn[i][j][i2][j2] += m * dyn[second][first][y2][x2];
                }
        }
    }
  while (Q--) {
    Read(i), Read(j), Read(second), Read(first);
    printf("%d\n", dyn[i][j][second][first]);
  }
  return (0);
}
