#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
char m[44][44];
int f[44][44][44][44];
int pre[44][44];
int main() {
  int i, j, x, y;
  cin >> N >> M >> Q;
  for (i = 1; i <= N; ++i) scanf("%s", m[i] + 1);
  for (i = 1; i <= N; ++i) {
    for (j = 1; j <= M; ++j) {
      if (m[i][j] == '1')
        pre[i][j] = j;
      else
        pre[i][j] = pre[i][j - 1];
    }
  }
  for (i = 1; i <= N; ++i)
    for (j = 1; j <= M; ++j)
      for (x = i; x <= N; ++x)
        for (y = j; y <= M; ++y) {
          f[i][j][x][y] =
              f[i][j][x - 1][y] + f[i][j][x][y - 1] - f[i][j][x - 1][y - 1];
          int now = j - 1;
          for (int k = x; k >= i; k--) {
            now = max(now, pre[k][y]);
            f[i][j][x][y] += y - now;
          }
        }
  while (Q--) {
    scanf("%d%d%d%d", &i, &j, &x, &y);
    printf("%d\n", f[i][j][x][y]);
  }
  return 0;
}
