#include <bits/stdc++.h>
using namespace std;
double eps = 1e-8;
int mod = int(1e9 + 7);
int n, m, q;
char s[45][45];
int a[45][45];
int sum[45][45];
int b[41][41][41][41];
int dp[41][41][41][41];
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    scanf(" %s", s[i]);
    for (int j = 0; j < m; j++) {
      a[i + 1][j + 1] = s[i][j] - '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int l = 1; l <= i; l++) {
        for (int r = 1; r <= j; r++) {
          int x = i - l;
          int y = j - r;
          if (sum[i][j] - sum[i][y] - sum[x][j] + sum[x][y] == 0)
            b[i][j][l][r] = 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int l = 1; l <= i; l++) {
        for (int r = 1; r <= j; r++) {
          int x = i - l;
          int y = j - r;
          dp[i][j][l][r] = dp[i][j][l - 1][r] + dp[i][j][l][r - 1] -
                           dp[i][j][l - 1][r - 1] + b[i][j][l][r];
        }
      }
    }
  }
  int a, b, c, d;
  while (q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int ans = 0;
    for (int i = a; i <= c; i++) {
      for (int j = b; j <= d; j++) {
        int l = i - a + 1;
        int r = j - b + 1;
        ans += dp[i][j][l][r];
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
