#include <bits/stdc++.h>
using namespace std;
int n, m, dp[44][44][44][44], l[44][44], q, x, y, xx, yy;
char a[44][44];
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == '0')
        l[i][j] = l[i][j - 1];
      else
        l[i][j] = j;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int ii = i; ii <= n; ii++)
        for (int jj = j; jj <= m; jj++) {
          int o = 0, l1 = j - 1;
          dp[i][j][ii][jj] = dp[i][j][ii - 1][jj] + dp[i][j][ii][jj - 1] -
                             dp[i][j][ii - 1][jj - 1];
          for (int k = ii; k >= i; k--) {
            l1 = max(l1, l[k][jj]);
            dp[i][j][ii][jj] += jj - l1;
          }
        }
  while (q--) {
    cin >> x >> y >> xx >> yy;
    cout << dp[x][y][xx][yy] << endl;
  }
  return 0;
}
