#include <bits/stdc++.h>
using namespace std;
int sum[45][45];
int ans[45][45][45][45];
int data[45][45];
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  memset(sum, 0, sizeof(sum));
  memset(ans, 0, sizeof(ans));
  memset(data, 0, sizeof(data));
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) data[i][j + 1] = (s[j] == '0' ? 1 : 0);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int a = 0, b = 0, c = 0, d = 0;
      a = sum[i - 1][j - 1];
      b = sum[i - 1][j];
      c = sum[i][j - 1];
      d = data[i][j];
      sum[i][j] = b + c - a + d;
    }
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++)
      for (int c = a; c <= n; c++)
        for (int d = b; d <= m; d++) {
          int f = sum[c][d] + sum[a - 1][b - 1] - sum[a - 1][d] - sum[c][b - 1];
          if (f == (c - a + 1) * (d - b + 1)) ans[a][b][c][d] = 1;
        }
  for (int a = n; a >= 0; a--)
    for (int b = 1; b <= m; b++)
      for (int c = a; c <= n; c++)
        for (int d = b; d <= m; d++) ans[a][b][c][d] += ans[a + 1][b][c][d];
  for (int a = 1; a <= n; a++)
    for (int b = m; b >= 0; b--)
      for (int c = a; c <= n; c++)
        for (int d = b; d <= m; d++) ans[a][b][c][d] += ans[a][b + 1][c][d];
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++)
      for (int c = a; c <= n; c++)
        for (int d = b; d <= m; d++) ans[a][b][c][d] += ans[a][b][c - 1][d];
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= m; b++)
      for (int c = a; c <= n; c++)
        for (int d = b; d <= m; d++) ans[a][b][c][d] += ans[a][b][c][d - 1];
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ans[a][b][c][d] << endl;
  }
  return 0;
}
