#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50;
bool b[MAXN][MAXN];
int h[MAXN][MAXN], ans[MAXN][MAXN][MAXN][MAXN];
void calc(int sx, int sy, int ex, int ey) {
  int cur = ans[sx][sy][ex - 1][ey] + ans[sx][sy][ex][ey - 1] -
            ans[sx][sy][ex - 1][ey - 1];
  int minh = ex - sx;
  for (int i = ey - 1; i >= sy; i--) {
    minh = min(minh, h[ex - 1][i]);
    cur += minh;
  }
  ans[sx][sy][ex][ey] = cur;
}
int main() {
  ios ::sync_with_stdio(0);
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char chr;
      cin >> chr;
      if (b[i][j] = (chr == '0')) {
        h[i][j] = 1;
        if (i) h[i][j] += h[i - 1][j];
      }
    }
  for (int sx = 0; sx < n; sx++)
    for (int sy = 0; sy < m; sy++)
      for (int ex = sx + 1; ex <= n; ex++)
        for (int ey = sy + 1; ey <= m; ey++) calc(sx, sy, ex, ey);
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    cout << ans[a][b][c][d] << "\n";
  }
}
