#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int n, m, q;
int g[44][44];
int cnt1[44][44][44][44], cnt2[44][44][44][44];
bool check2(int r, int c, int a, int b) {
  if (r + a - 1 > n) return false;
  if (c + b - 1 > m) return false;
  for (int i = r; i < r + a; i++)
    for (int j = c; j < c + b; j++)
      if (g[i][j] == 1) return false;
  return true;
}
bool check1(int r, int c, int a, int b) {
  if (r - a + 1 <= 0) return false;
  if (c - b + 1 <= 0) return false;
  for (int i = r - a + 1; i <= r; i++)
    for (int j = c - b + 1; j <= c; j++)
      if (g[i][j] == 1) return false;
  return true;
}
void init() {
  for (int i = 1; i <= n; i++) {
    int tmp[44][44][44];
    for (int j = 1; j <= m; j++)
      for (int a = 1; a <= n; a++)
        for (int b = 1; b <= m; b++) {
          tmp[j][a][b] = tmp[j - 1][a][b] + check1(i, j, a, b);
          cnt1[i][j][a][b] = cnt1[i - 1][j][a][b] + tmp[j][a][b];
        }
  }
  for (int i = 1; i <= n; i++) {
    int tmp[44][44][44];
    for (int j = 1; j <= m; j++)
      for (int a = 1; a <= n; a++)
        for (int b = 1; b <= m; b++) {
          tmp[j][a][b] = tmp[j - 1][a][b] + check2(i, j, a, b);
          cnt2[i][j][a][b] = cnt2[i - 1][j][a][b] + tmp[j][a][b];
        }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      g[i][j] = (int)(c - '0');
    }
  init();
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ans = 0;
    for (int i = 1; i <= c - a + 1; i++)
      for (int j = 1; j <= d - b + 1; j++) {
        ans += cnt1[c][d][i][j] - cnt1[c][b - 1 + j - 1][i][j] -
               cnt1[a - 1 + i - 1][d][i][j] +
               cnt1[a - 1 + i - 1][b - 1 + j - 1][i][j];
      }
    cout << ans << endl;
  }
  return 0;
}
