#include <bits/stdc++.h>
using namespace std;
char str[50][50];
int is[50][50];
int s1[50][50];
int s2[50][50];
int n, m, q;
long long dp[50][50][50][50];
int dx[] = {1, 1, -1, -1};
int in(int x1, int y1, int x2, int y2) { return x2 >= x1 && y2 >= y1; }
int check(int x1, int y1, int x2, int y2) {
  int ans = s2[x2][y2] - s2[x1 - 1][y2] - s2[x2][y1 - 1] + s2[x1 - 1][y1 - 1];
  return ans == (y2 - y1 + 1) * (x2 - x1 + 1);
}
long long dfs(int, int, int, int);
long long dfs2(int* x, int d, int cnt) {
  if (d == 4) {
    if (!cnt) return 0;
    if (!in(x[0], x[1], x[2], x[3])) return 0;
    int ans = dfs(x[0], x[1], x[2], x[3]);
    if (cnt & 1) return ans;
    return -ans;
  }
  int ans = 0;
  ans += dfs2(x, d + 1, cnt);
  x[d] += dx[d];
  ans += dfs2(x, d + 1, cnt + 1);
  x[d] -= dx[d];
  return ans;
}
long long dfs(int x1, int y1, int x2, int y2) {
  long long& ans = dp[x1][y1][x2][y2];
  if (ans >= 0) return ans;
  int x[4] = {x1, y1, x2, y2};
  int y[4];
  ans = dfs2(x, 0, 0);
  if (check(x1, y1, x2, y2)) ++ans;
  return ans;
}
int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; ++i) scanf("%s", str[i]);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      s1[i + 1][j + 1] = str[i][j] == '0';
      s1[i + 1][j + 1] += s1[i + 1][j];
      s2[i + 1][j + 1] = s1[i + 1][j + 1];
      s2[i + 1][j + 1] += s2[i][j + 1];
    }
  memset(dp, -1, sizeof(dp));
  dfs(1, 1, n, m);
  while (q--) {
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    printf("%I64d\n", dp[x1][y1][x2][y2]);
  }
}
