#include <bits/stdc++.h>
using namespace std;
long long int dir[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int ans[50][50][50][50], n, m, q;
char mat[50][50];
bool vis[50][50];
int calc(int a, int b, int c, int d) {
  for (int i = c; i <= a; i++)
    for (int j = d; j <= b; j++) vis[i][j] = 1 - (mat[i][j] - '0');
  for (int i = a; i >= c; i--)
    for (int j = b - 1; j >= d; j--) vis[i][j] = vis[i][j] & vis[i][j + 1];
  for (int j = b; j >= d; j--)
    for (int i = a - 1; i >= c; i--) vis[i][j] = vis[i][j] & vis[i + 1][j];
  int cnt = 0;
  for (int i = c; i <= a; i++)
    for (int j = d; j <= b; j++) cnt += vis[i][j];
  return cnt;
}
void fill() {
  memset(ans, 0, sizeof(ans));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans[i][j][i][j] = 1 - (mat[i][j] - '0');
      for (int a = i; a <= n; a++) {
        for (int b = j; b <= m; b++) {
          if (a == i && b == j) continue;
          ans[i][j][a][b] += ans[i][j][a - 1][b] + ans[i][j][a][b - 1] -
                             ans[i][j][a - 1][b - 1] + calc(a, b, i, j);
        }
      }
    }
  }
}
void solve() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mat[i][j];
  fill();
  int a, b, c, d;
  while (q--) {
    cin >> a >> b >> c >> d;
    cout << ans[a][b][c][d] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
