#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
int sum[44][44];
int cnt[44][44][44][44];
int n, m, q;
char c[44][44];
bool isgood(int xa, int ya, int xb, int yb) {
  return (sum[xa][ya] - sum[xa][yb] - sum[xb][ya] + sum[xb][yb] == 0);
}
int main() {
  ios::sync_with_stdio(false);
  int x, y, xx, yy;
  int xa, ya, xb, yb;
  for (; ~scanf("%d%d%d", &m, &n, &q);) {
    for (x = 0; x < m; x++) scanf("%s", c[x]);
    for (x = 0; x < m; x++)
      for (y = 0; y < n; y++) {
        sum[x + 1][y + 1] = sum[x + 1][y] + sum[x][y + 1] - sum[x][y] +
                            ((c[x][y] != '0') ? 1 : 0);
      }
    memset(cnt, 0, sizeof(cnt));
    for (x = 0; x < m; x++)
      for (y = 0; y < n; y++) {
        for (xx = x + 1; xx <= m; xx++)
          for (yy = y + 1; yy <= n; yy++) {
            cnt[x][y][xx + 1][yy + 1] =
                cnt[x][y][xx + 1][yy] + cnt[x][y][xx][yy + 1] -
                cnt[x][y][xx][yy] + (isgood(x, y, xx, yy) ? 1 : 0);
          }
      }
    for (; q--;) {
      xa = in() - 1;
      ya = in() - 1;
      xb = in();
      yb = in();
      int ans = 0;
      for (x = xa; x < xb; x++)
        for (y = ya; y < yb; y++) {
          ans += cnt[x][y][xb + 1][yb + 1];
        }
      printf("%d\n", ans);
    }
  }
  return 0;
}
