#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int dp[N + 10][N + 10][N + 10][N + 10];
int c[N + 10][N + 10][N + 10];
char a[N + 10][N + 10];
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i1 = 1; i1 <= n; i1++)
    for (int j1 = 1; j1 <= m; j1++) {
      memset(c, 0, sizeof c);
      for (int i = i1; i <= n; i++)
        for (int j = j1; j <= m; j++) {
          dp[i1][j1][i][j] = dp[i1][j1][i - 1][j] + dp[i1][j1][i][j - 1] -
                             dp[i1][j1][i - 1][j - 1];
          for (int x = i; x >= i1; x--) {
            if (a[x][j] != '0') break;
            c[i][j][x] = c[i][j - 1][x] + 1;
            dp[i1][j1][i][j] += c[i][j][x];
          }
        }
    }
  while (q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << dp[x1][y1][x2][y2] << endl;
  }
  return 0;
}
