#include <bits/stdc++.h>
using namespace std;
int n, m, q, a, b, c, d;
char linha[42][42];
int pd[42][42][42][42];
int doit(int a, int b, int c, int d) {
  if (a > c) return 0;
  if (b > d) return 0;
  if (pd[a][b][c][d] != -1) return pd[a][b][c][d];
  int resp = 0;
  resp += doit(a + 1, b, c, d);
  resp += doit(a, b + 1, c, d);
  resp -= doit(a + 1, b + 1, c, d);
  int menor = d;
  for (int i = a; i <= c; i++) {
    if (linha[i][b] == '1') break;
    for (int j = b; j <= menor; j++) {
      if (linha[i][j] == '1') {
        menor = min(menor, j - 1);
        break;
      }
      resp++;
    }
  }
  return pd[a][b][c][d] = resp;
}
int main(void) {
  memset(pd, -1, sizeof pd);
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf("%s", linha[i]);
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    a--;
    b--;
    c--;
    d--;
    printf("%d\n", doit(a, b, c, d));
  }
  return 0;
}
