#include <bits/stdc++.h>
using namespace std;
char grid[40][41];
bool isgood[50][50][50][50];
int sum[50][50][50][50];
int dp[50][50][50][50], newdp[50][50][50][50], n, m;
int solve(int i1, int j1, int i2, int j2) {
  if (i1 >= n || j1 >= m || i2 < 0 || j2 < 0 || i1 > i2 || j1 > j2) return 0;
  if (dp[i1][j1][i2][j2] != -1) return dp[i1][j1][i2][j2];
  int ret = isgood[i1][j1][i2][j2];
  for (int k = 0; k < 2; k++)
    for (int l = 0; l < 2; l++)
      for (int u = 0; u < 2; u++)
        for (int v = 0; v < 2; v++) {
          if (!k && !l && !u && !v) continue;
          if ((k + l + u + v) % 2)
            ret += solve(i1 + k, j1 + l, i2 - u, j2 - v) +
                   solve(i1 + k, j1 + l, i2 - u, j2 - v) -
                   solve(i1 + k, j1 + l, i2 - u, j2 - v);
          else
            ret -= solve(i1 + k, j1 + l, i2 - u, j2 - v) +
                   solve(i1 + k, j1 + l, i2 - u, j2 - v) -
                   solve(i1 + k, j1 + l, i2 - u, j2 - v);
        }
  return dp[i1][j1][i2][j2] = ret;
}
int main() {
  int q, r1, r2, c1, c2;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%s", grid[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = i; k >= 0; k--)
        for (int l = j; l >= 0; l--) {
          sum[k][l][i][j] = sum[k][l + 1][i][j] + sum[k + 1][l][i][j] -
                            sum[k + 1][l + 1][i][j] + (grid[k][l] - '0');
          if (!sum[k][l][i][j]) isgood[k][l][i][j] = 1;
        }
  memset(dp, -1, sizeof(dp));
  dp[0][0][n - 1][m - 1] = solve(0, 0, n - 1, m - 1);
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
    r1--;
    c1--;
    r2--;
    c2--;
    printf("%d\n", dp[r1][c1][r2][c2]);
  }
  return 0;
}
