#include <bits/stdc++.h>
using namespace std;
char x;
int m, n, q;
int s[50][50];
int f[50][50][50];
int g[50][50][50];
int dp[50][50][50][50];
int cmp[50];
int get(int x, int y, int u, int v) {
  int z = (s[u][v] - s[x - 1][v] - s[u][y - 1] + s[x - 1][y - 1]);
  return (z == (u - x + 1) * (v - y + 1));
}
int main() {
  memset(s, 0, sizeof(s));
  memset(dp, 0, sizeof(dp));
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(f));
  cin >> m >> n >> q;
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) {
      cin >> x;
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (x == '0');
    }
  for (int x = m; x >= 1; x--)
    for (int y = n; y >= 1; y--) {
      for (int i = x; i <= m; i++)
        for (int j = y; j <= n; j++) {
          f[y][i][j] += get(x, y, i, j);
          g[y][i][j] = f[y][i][j] + g[y + 1][i][j];
        }
      memset(cmp, 0, sizeof(cmp));
      for (int i = x; i <= m; i++)
        for (int j = y; j <= n; j++) {
          cmp[j] += g[y][i][j];
          dp[x][y][i][j] = dp[x][y][i][j - 1] + cmp[j];
        }
    }
  int a, b, c, d;
  for (int i = 1; i <= q; i++) {
    cin >> a >> b >> c >> d;
    cout << dp[a][b][c][d] << "\n";
  }
  return 0;
}
