#include <bits/stdc++.h>
using namespace std;
const long long oo = 1LL << 40;
const int MAXN = 50;
int n, m, q;
int ls[MAXN][MAXN];
int dp[MAXN][MAXN][MAXN][MAXN];
int main() {
  int ch;
  while (cin >> n) {
    cin >> m >> q;
    memset(dp, 0, sizeof(dp));
    memset(ls, 0, sizeof(ls));
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%1d", &ch);
        ls[i][j] = ls[i - 1][j];
        if (ch == 1)
          ls[i][j] = 0;
        else
          ls[i][j]++;
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        for (int ki = i; ki <= n; ki++)
          for (int kj = j; kj <= m; kj++) {
            dp[i][j][ki][kj] = dp[i][j][ki][kj - 1] + dp[i][j][ki - 1][kj] -
                               dp[i][j][ki - 1][kj - 1];
            int r = ki - i + 1;
            for (int c = kj; c >= j; c--) {
              r = min(r, ls[ki][c]);
              dp[i][j][ki][kj] += r;
            }
          }
      }
    while (q--) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      cout << dp[a][b][c][d] << endl;
    }
  }
  return 0;
}
