#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double EPS = 1e-7;
const int MAXR = 40;
const int MAXC = 40;
int R, C, Q;
int data[MAXR + 5][MAXC + 5];
int memo[MAXR + 5][MAXC + 5][MAXR + 5][MAXC + 5];
int main() {
  scanf("%d %d %d", &R, &C, &Q);
  for (int(i) = 0, (_batas) = (R); (i) < (_batas); (i)++)
    for (int(j) = 0, (_batas) = (C); (j) < (_batas); (j)++)
      scanf("%1d", &data[i][j]);
  for (int r_end = R - 1; r_end >= 0; r_end--) {
    for (int c_end = C - 1; c_end >= 0; c_end--) {
      int r_atap = -1;
      for (int c_beg = c_end; c_beg >= 0; c_beg--) {
        for (int r_beg = r_end; r_beg >= 0; r_beg--) {
          if (data[r_beg][c_beg] == 1) r_atap = max(r_atap, r_beg);
          memo[r_beg][c_beg][r_end][c_end] = r_end - max(r_atap + 1, r_beg) + 1;
          if (c_beg + 1 < C)
            memo[r_beg][c_beg][r_end][c_end] +=
                memo[r_beg][c_beg + 1][r_end][c_end];
        }
      }
    }
  }
  for (int(i) = 0, (_batas) = (Q); (i) < (_batas); (i)++) {
    int r1, c1, r2, c2;
    scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
    r1--, c1--, r2--, c2--;
    int ans = 0;
    for (int(r) = (r1), (_batas) = (r2); (r) <= (_batas); (r)++)
      for (int(c) = (c1), (_batas) = (c2); (c) <= (_batas); (c)++) {
        ans += memo[r1][c1][r][c];
      }
    printf("%d\n", ans);
  }
  return 0;
}
