#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 50 + 10, M = 1e6 + 10, inf = 1e9 + 10;
const long long INF = 5e17 + 10, mod = 1e9 + 7;
int a[N][N], cnt[N][N][N][N];
int s[N][N], sum[N][N][N][N];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &a[i][j]);
      s[i][j] = a[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      for (int k = i; k <= n; k++) {
        for (int l = j; l <= m; l++) {
          int x = s[k][l] - s[i - 1][l] - s[k][j - 1] + s[i - 1][j - 1];
          cnt[i][j][k][l] = cnt[i][j][k][l - 1] + cnt[i][j][k - 1][l] -
                            cnt[i][j][k - 1][l - 1] + !x;
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      for (int k = i; k <= n; k++) {
        for (int l = j; l <= m; l++) {
          sum[i][j][k][l] = sum[i + 1][j][k][l] + sum[i][j + 1][k][l] -
                            sum[i + 1][j + 1][k][l] + cnt[i][j][k][l];
        }
      }
    }
  }
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", sum[a][b][c][d]);
  }
  return 0;
}
