#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const double pi = 2 * asin(1.0);
int n;
int m;
int a[50][50];
int s[42][42], f[42][42][42][42], g[42][42][42][42], h[42][42][42][42];
int main() {
  int q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) a[i][j] = s[j - 1] - '0';
  }
  for (int i = n; i >= 1; i--)
    for (int j = m; j >= 1; j--) {
      s[i][j] = s[i + 1][j] + s[i][j + 1] - s[i + 1][j + 1] + a[i][j];
      for (int k = i; k <= n; k++)
        for (int l = j; l <= m; l++) {
          f[i][j][k][l] =
              int((s[i][j] - s[k + 1][j] - s[i][l + 1] + s[k + 1][l + 1]) == 0);
          g[i][j][k][l] = g[i][j][k - 1][l] + g[i][j][k][l - 1] -
                          g[i][j][k - 1][l - 1] + f[i][j][k][l];
          h[i][j][k][l] = h[i + 1][j][k][l] + h[i][j + 1][k][l] -
                          h[i + 1][j + 1][k][l] + g[i][j][k][l];
        }
    }
  for (int i = 0; i < q; i++) {
    int x1, x2, y8687969, y2;
    scanf("%d%d%d%d", &x1, &y8687969, &x2, &y2);
    printf("%d\n", h[x1][y8687969][x2][y2]);
  }
  return 0;
}
