#include <bits/stdc++.h>
using namespace std;
char re[100][100];
int rec[100][100];
int g[50][50][50][50], f[50][50][50][50];
bool check[50][50][50][50];
int last[50][50];
int n, m, q;
int gdp(int a, int b, int c, int d) {
  int i, j;
  if ((a > b) || (c > d)) return 0;
  if (check[a][b][c][d]) return g[a][b][c][d];
  check[a][b][c][d] = true;
  if (last[b][d] < c)
    g[a][b][c][d] =
        ((d - c + 1) * (d - c) / 2 + d - c + 1) + gdp(a, b - 1, c, d);
  else
    g[a][b][c][d] = gdp(a, b, c, last[b][d] - 1) + gdp(a, b, last[b][d] + 1, d);
  return g[a][b][c][d];
}
int main() {
  int i, j, ans, a, b, c, d, i1, i2, j1, j2;
  int lie, hang, shu;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++) {
    scanf("%s", re[i] + 1);
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) rec[i][j] = re[i][j] - '0';
  for (i1 = 0; i1 <= n; i1++)
    for (i2 = 0; i2 <= n; i2++)
      for (j1 = 0; j1 <= m; j1++)
        for (j2 = 0; j2 <= m; j2++)
          check[i1][i2][j1][j2] = false, f[i1][i2][j1][j2] = 0;
  for (i = 1; i <= n; i++) {
    if (rec[i][1])
      last[i][1] = 1;
    else
      last[i][1] = 0;
    for (j = 2; j <= m; j++)
      if (rec[i][j])
        last[i][j] = j;
      else
        last[i][j] = last[i][j - 1];
  }
  for (a = 1; a <= n; a++)
    for (b = a; b <= n; b++)
      for (c = 1; c <= m; c++)
        for (d = c; d <= m; d++)
          f[a][b][c][d] = f[a][b - 1][c][d] + gdp(a, b, c, d);
  for (int ii = 1; ii <= q; ii++) {
    scanf("%d%d%d%d", &a, &c, &b, &d);
    printf("%d\n", f[a][b][c][d]);
  }
}
