#include <bits/stdc++.h>
using namespace std;
int accum[45][45], memo[45][45][45][45];
char arr[45][45];
int n, m, q;
int get(int a, int b, int c, int d) {
  int ret =
      accum[c][d] - accum[a - 1][d] - accum[c][b - 1] + accum[a - 1][b - 1];
  return !ret;
}
int solve(int a, int b, int c, int d) {
  if (memo[a][b][c][d] != -1) return memo[a][b][c][d];
  int ret = get(a, b, c, d);
  if (c > a) ret += solve(a, b, c - 1, d);
  if (d > b) ret += solve(a, b, c, d - 1);
  if (c > a && d > b) ret -= solve(a, b, c - 1, d - 1);
  return memo[a][b][c][d] = ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  memset(memo, -1, sizeof memo);
  for (auto i = 1; i <= (long long)(n); i++) {
    for (auto j = 1; j <= (long long)(m); j++) {
      cin >> arr[i][j];
      accum[i][j] = arr[i][j] - '0';
    }
  }
  for (auto i = 1; i <= (long long)(n); i++)
    for (auto j = 1; j <= (long long)(m); j++)
      accum[i][j] += (accum[i][j - 1] + accum[i - 1][j] - accum[i - 1][j - 1]);
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ret = 0;
    for (auto i = a; i <= (long long)(c); i++)
      for (auto j = b; j <= (long long)(d); j++) ret += solve(i, j, c, d);
    cout << ret << '\n';
  }
  return 0;
}
