#include <bits/stdc++.h>
using namespace std;
const int MX = 45, INF = 1000000000, mod = 1000000007;
const long long int LINF = 1000000000000000000ll;
const double eps = 1e-10;
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
char cs[45];
int a[MX][MX];
int e[MX][MX][MX][MX];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf("%s", cs);
    for (int j = 0; j < m; j++) a[i][j] = cs[j] - '0';
  }
  for (int i1 = 0; i1 < n; i1++)
    for (int j1 = 0; j1 < m; j1++) {
      for (int i = 0; i + i1 < n; i++)
        for (int j = 0; j + j1 < m; j++) {
          int i2 = i1 + i, j2 = j1 + j;
          if (i == i2 && j == j2)
            e[i][j][i2][j2] = !a[i][j];
          else {
            if (i == i2) {
              e[i][j][i2][j2] = (e[i][j][i2][j2 - 1] & e[i][j2][i2][j2]);
            } else {
              e[i][j][i2][j2] = (e[i][j][i2 - 1][j2] & e[i2][j][i2][j2]);
            }
          }
        }
    }
  for (int i1 = 0; i1 < n; i1++)
    for (int j1 = 0; j1 < m; j1++) {
      for (int i = 0; i + i1 < n; i++)
        for (int j = 0; j + j1 < m; j++) {
          int i2 = i1 + i, j2 = j1 + j;
          if (i == i2 && j == j2) continue;
          int x = 0;
          if (i == i2) {
            x += e[i][j][i][j2 - 1];
            x += e[i][j + 1][i][j2];
            x -= e[i][j + 1][i][j2 - 1];
          } else if (j == j2) {
            x += e[i][j][i2 - 1][j];
            x += e[i + 1][j][i2][j];
            x -= e[i + 1][j][i2 - 1][j];
          } else {
            x += e[i][j][i2][j2 - 1];
            x += e[i][j + 1][i2][j2];
            x += e[i][j][i2 - 1][j2];
            x += e[i + 1][j][i2][j2];
            x -= e[i + 1][j][i2 - 1][j2];
            x -= e[i][j + 1][i2][j2 - 1];
            x -= e[i + 1][j + 1][i2][j2];
            x -= e[i][j + 1][i2 - 1][j2];
            x -= e[i + 1][j][i2][j2 - 1];
            x -= e[i][j][i2 - 1][j2 - 1];
            x += e[i + 1][j + 1][i2 - 1][j2];
            x += e[i + 1][j + 1][i2][j2 - 1];
            x += e[i + 1][j][i2 - 1][j2 - 1];
            x += e[i][j + 1][i2 - 1][j2 - 1];
            x -= e[i + 1][j + 1][i2 - 1][j2 - 1];
          }
          e[i][j][i2][j2] += x;
        }
    }
  int a, b, c, d;
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    a--;
    b--;
    c--;
    d--;
    printf("%d\n", e[a][b][c][d]);
  }
  return 0;
}
