#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int ar[45][45];
int lf[45][45];
int mn[45][45][45];
int dp[45][45][45][45];
void read() {
  char str[45];
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str + 1);
    for (int j = 1; j <= m; j++) ar[i][j] = str[j] - '0';
  }
  return;
}
void init() {
  int i, j, k, y;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (ar[i][j] == 1)
        lf[i][j] = 0;
      else
        lf[i][j] = lf[i][j - 1] + 1;
  for (y = 1; y <= m; y++)
    for (i = 1; i <= n; i++)
      for (j = i; j <= n; j++) {
        mn[y][i][j] = lf[i][y];
        for (k = i; k <= j; k++) mn[y][i][j] = min(mn[y][i][j], lf[k][y]);
      }
  return;
}
void solve() {
  int i, j, x, y, a, b;
  for (y = 1; y <= m; y++)
    for (j = 1; j <= y; j++)
      for (x = 1; x <= n; x++)
        for (i = 1; i <= x; i++) {
          if (y == j)
            dp[i][j][x][y] = 0;
          else
            dp[i][j][x][y] = dp[i][j][x][y - 1];
          for (a = i; a <= x; a++)
            for (b = a; b <= x; b++)
              dp[i][j][x][y] +=
                  (((y - j + 1) < (mn[y][a][b])) ? (y - j + 1) : (mn[y][a][b]));
        }
  while (q--) {
    scanf("%d %d %d %d", &i, &j, &x, &y);
    printf("%d\n", dp[i][j][x][y]);
  }
  return;
}
int main() {
  read();
  init();
  solve();
  return 0;
}
