#include <bits/stdc++.h>
using namespace std;
const double eps = 0.000000000000001;
int n, m, q;
int A[50][50];
char s[50][50];
int dp[50][50][50][50];
void pre() {
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (s[i][j] == '1') {
        A[i][j] = 0;
      } else {
        A[i][j] = A[i - 1][j] + 1;
      }
    }
  }
  int k;
  for (int oop = 1; oop <= n; oop++) {
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        int sm = 0, mn = oop;
        for (k = 1; k <= m && j - k + 1 >= 1; k++) {
          mn = min(mn, A[i][j - k + 1]);
          sm += mn;
          dp[i][j][oop][k] = sm;
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  int i, j;
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
  }
  pre();
  while (q--) {
    int x1, y1, x2, y2;
    scanf("%d%d%d", &x1, &y1, &x2);
    scanf("%d", &y2);
    long long ans = 0;
    for (i = x1; i <= x2; i++) {
      for (j = y1; j <= y2; j++) {
        ans += dp[i][j][i - x1 + 1][j - y1 + 1];
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
