#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const double EPS = 1e-8;
const int INF = 0x3fffffff;
const int MX = 41;
int g_m, g_n, g_k;
int in[MX][MX];
int sum[MX][MX];
int dp[MX][MX][MX][MX];
bool input() {
  cin >> g_m >> g_n >> g_k;
  if (cin.eof()) return false;
  for (int i = 1; i <= g_m; ++i) {
    for (int j = 1; j <= g_n; ++j) {
      scanf("%1d", &in[i][j]);
      sum[i][j] = sum[i][j - 1];
      if (in[i][j] == 1)
        sum[i][j] = 0;
      else
        ++sum[i][j];
    }
  }
  return true;
}
void solve() {
  int x_1, y_1, x_2, y_2;
  for (x_1 = 1; x_1 <= g_m; ++x_1) {
    for (y_1 = 1; y_1 <= g_n; ++y_1) {
      for (x_2 = x_1; x_2 <= g_m; ++x_2) {
        for (y_2 = y_1; y_2 <= g_n; ++y_2) {
          dp[x_1][y_1][x_2][y_2] = dp[x_1][y_1][x_2][y_2 - 1] +
                                   dp[x_1][y_1][x_2 - 1][y_2] -
                                   dp[x_1][y_1][x_2 - 1][y_2 - 1];
          int n = y_2 - y_1 + 1;
          for (int x_t = x_2; x_t >= x_1; --x_t) {
            n = min(n, sum[x_t][y_2]);
            dp[x_1][y_1][x_2][y_2] += n;
          }
        }
      }
    }
  }
  for (int i = 0; i < g_k; ++i) {
    scanf("%d%d%d%d", &x_1, &y_1, &x_2, &y_2);
    printf("%d\n", dp[x_1][y_1][x_2][y_2]);
  }
}
int main() {
  while (input()) {
    solve();
  }
  return 0;
}
