#include <bits/stdc++.h>
using namespace std;
char grid[50][50];
int H[50];
int stk[50];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = (int)(0); i < (int)(n); i++) scanf("%s", grid[i]);
  while (q--) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int ans = 0;
    memset(H, 0, sizeof H);
    a--;
    b--;
    for (int i = (int)(a); i < (int)(c); i++) {
      int N = 1;
      for (int j = (int)(b); j < (int)(d); j++) {
        H[N]++;
        if (grid[i][j] == '1') H[N] = 0;
        N++;
      }
      H[0] = 0;
      H[N++] = 0;
      int top = 0;
      for (int i = (int)(0); i < (int)(N); i++) {
        while (top > 1 && H[stk[top - 1]] >= H[i]) {
          top--;
          int h = H[stk[top]];
          int le = stk[top - 1];
          int ri = i;
          int w1 = stk[top] - le;
          int w2 = ri - stk[top];
          int plus = h * w1 * w2;
          ans += plus;
        }
        stk[top++] = i;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
