#include <bits/stdc++.h>
using namespace std;
int m, n, q, x, y, xx, yy, xa, ya, xb, yb, sum[44][44], cnt[44][44][44][44];
char s[44][44];
bool isGood(int xa, int ya, int xb, int yb) {
  return sum[xa][ya] - sum[xa][yb] - sum[xb][ya] + sum[xb][yb] == 0;
}
int main() {
  cin >> m >> n >> q;
  for (int i = 0; i < m; i++) cin >> s[i];
  for (x = 0; x < m; x++)
    for (y = 0; y < n; y++)
      sum[x + 1][y + 1] =
          sum[x + 1][y] + sum[x][y + 1] - sum[x][y] + (s[x][y] != '0' ? 1 : 0);
  for (x = 0; x < m; x++)
    for (y = 0; y < n; y++)
      for (xx = x + 1; xx <= m; xx++)
        for (yy = y + 1; yy <= n; yy++)
          cnt[x][y][xx + 1][yy + 1] =
              cnt[x][y][xx + 1][yy] + cnt[x][y][xx][yy + 1] -
              cnt[x][y][xx][yy] + (isGood(x, y, xx, yy) ? 1 : 0);
  for (int i = 0; i < q; i++) {
    cin >> xa >> ya >> xb >> yb;
    xa--;
    ya--;
    int ans = 0;
    for (x = xa; x < xb; x++)
      for (y = ya; y < yb; y++) ans += cnt[x][y][xb + 1][yb + 1];
    cout << ans;
    if (i != q - 1) cout << endl;
  }
  return 0;
}
