#include <bits/stdc++.h>
using namespace std;
const int MAXN = 41;
int grid[MAXN][MAXN];
int dp[MAXN][MAXN][MAXN][MAXN];
int cums[MAXN][MAXN];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      grid[i][j] = c - '0';
    }
  }
  for (int col = 1; col <= m; col++) {
    for (int row = 1; row <= n; row++) {
      if (row == 1) {
        cums[row][col] = !grid[row][col];
      } else {
        if (grid[row][col] == 0) {
          cums[row][col] += !grid[row][col] + cums[row - 1][col];
        } else
          cums[row][col] = 0;
      }
    }
  }
  for (int r1 = 1; r1 <= n; r1++) {
    for (int c1 = 1; c1 <= m; c1++) {
      for (int r2 = r1; r2 <= n; r2++) {
        for (int c2 = c1; c2 <= m; c2++) {
          dp[r1][c1][r2][c2] += dp[r1][c1][r2 - 1][c2] +
                                dp[r1][c1][r2][c2 - 1] -
                                dp[r1][c1][r2 - 1][c2 - 1];
          int minh = 100;
          for (int c3 = c2; c3 >= c1; c3--) {
            if (grid[r2][c3] == 1) break;
            minh = min(min(cums[r2][c3], r2 - r1 + 1), minh);
            dp[r1][c1][r2][c2] += minh;
          }
        }
      }
    }
  }
  while (k--) {
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    cout << dp[r1][c1][r2][c2] << endl;
  }
  return 0;
}
