#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int matrix[52][52];
long long pref[3][52][52];
long long all[2][52][52][52][52];
void precalculate() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = i; k <= n; k++) {
        for (int ij = j; ij <= m; ij++) {
          all[1][i][j][k][ij] = all[1][i][j][k][ij - 1] +
                                all[1][i][j][k - 1][ij] -
                                all[1][i][j][k - 1][ij - 1];
          int r = ij - j + 1;
          for (int c = k; c >= i && r > 0; c--) {
            r = (r > pref[2][c][ij]) ? pref[2][c][ij] : r;
            all[1][i][j][k][ij] += r;
          }
        }
      }
    }
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c = '2';
      while (c != '0' && c != '1') scanf("%c", &c);
      matrix[i][j] = c - 48;
      pref[2][i][j] = pref[2][i][j - 1];
      if (matrix[i][j] == 1)
        pref[2][i][j] = 0;
      else
        pref[2][i][j]++;
    }
  }
  precalculate();
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << all[1][a][b][c][d] << endl;
  }
  return 0;
}
