#include <bits/stdc++.h>
using namespace std;
int n, m, q;
char str[45][45];
int T[45][45][45][45];
int cnt[45][45];
int main() {
  int i, j, k, ii, kk;
  cin >> n >> m >> q;
  for (i = 0; i < n; i++) scanf("%s", str[i]);
  for (i = 0; i < n; i++)
    for (k = 0; k < m; k++) {
      for (ii = i; ii < n; ii++)
        for (kk = k; kk < m; kk++) {
          if (i == ii && k == kk) {
            T[i][k][ii][kk] = 1 - (str[i][k] - '0');
            cnt[ii][kk] = 1 - (str[i][k] - '0');
            continue;
          }
          cnt[ii][kk] = 0;
          for (j = kk; j >= k; j--) {
            if (str[ii][j] == '1') break;
            cnt[ii][kk]++;
          }
          T[i][k][ii][kk] = 0;
          if (ii > i) T[i][k][ii][kk] += T[i][k][ii - 1][kk];
          if (kk > k) T[i][k][ii][kk] += T[i][k][ii][kk - 1];
          if (ii > i && kk > k) T[i][k][ii][kk] -= T[i][k][ii - 1][kk - 1];
          int tot = cnt[ii][kk];
          for (j = ii; j >= i; j--) {
            tot = min(tot, cnt[j][kk]);
            T[i][k][ii][kk] += tot;
          }
        }
    }
  while (q--) {
    scanf("%d%d%d%d", &i, &k, &ii, &kk);
    i--, k--, ii--, kk--;
    cout << T[i][k][ii][kk] << endl;
  }
  return 0;
}
