#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 50;
int n, m, q;
string mat[N];
int res[N][N][N][N];
int zeros[N];
void go(int i0, int j0) {
  res[i0][j0][i0][j0] = (mat[i0][j0] == '0');
  int at = (mat[i0][j0] == '0');
  for (int i1 = i0 + 1; i1 < n; i1++) {
    if (mat[i1][j0] == '0')
      at++;
    else
      at = 0;
    res[i0][j0][i1][j0] = res[i0][j0][i1 - 1][j0] + at;
  }
  at = (mat[i0][j0] == '0');
  for (int j1 = j0 + 1; j1 < m; j1++) {
    if (mat[i0][j1] == '0')
      at++;
    else
      at = 0;
    res[i0][j0][i0][j1] = res[i0][j0][i0][j1 - 1] + at;
    for (int jj = j0; jj <= j1; jj++) zeros[jj] = (mat[i0][jj] == '0');
    for (int i1 = i0 + 1; i1 < n; i1++) {
      stack<int> s;
      int sum = 0;
      res[i0][j0][i1][j1] = res[i0][j0][i1 - 1][j1];
      for (int jj = j0; jj <= j1; jj++) {
        if (mat[i1][jj] == '1') {
          zeros[jj] = 0;
          sum = 0;
          while (s.size()) s.pop();
        } else {
          int val = ++zeros[jj];
          int cnt = 1;
          while (s.size() and val < s.top()) {
            sum -= s.top();
            cnt++;
            s.pop();
          }
          while (cnt--) {
            s.push(val);
            sum += val;
          }
        }
        res[i0][j0][i1][j1] += sum;
      }
    }
  }
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> mat[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) go(i, j);
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    cout << res[a][b][c][d] << endl;
  }
  return 0;
}
