#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int, int>;
int read() {
  int x = 0, sgn = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') sgn = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return x * sgn;
}
const int N = 55;
ll f[N][N][N][N], pre[N][N];
int n, m, q;
char s[N];
void solve() {
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++) {
      pre[i][j] = s[j] == '0' ? pre[i - 1][j] + 1 : 0;
    }
  }
  for (int x1 = 1; x1 <= n; x1++)
    for (int y_alpha_1 = 1; y_alpha_1 <= m; y_alpha_1++)
      for (int x2 = x1; x2 <= n; x2++)
        for (int y2 = y_alpha_1; y2 <= m; y2++) {
          f[x1][y_alpha_1][x2][y2] = f[x1][y_alpha_1][x2 - 1][y2] +
                                     f[x1][y_alpha_1][x2][y2 - 1] -
                                     f[x1][y_alpha_1][x2 - 1][y2 - 1];
          ll t = x2 - x1 + 1;
          for (int j = y2; j >= y_alpha_1; j--) {
            t = min(t, pre[x2][j]);
            f[x1][y_alpha_1][x2][y2] += t;
          }
        }
}
int main() {
  n = read(), m = read(), q = read();
  solve();
  for (int i = 1, a, b, c, d; i <= q; i++)
    a = read(), b = read(), c = read(), d = read(),
    printf("%lld\n", f[a][b][c][d]);
  return 0;
}
