#include <bits/stdc++.h>
int st[1000000], n, m, q, a, b, c, d, h[100], ans, sum;
char map[100][100];
int main() {
  scanf("%d%d%d\n", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) scanf("%c", &map[i][j]);
    scanf("\n");
  }
  while (q--) {
    scanf("%d%d%d%d\n", &a, &b, &c, &d);
    for (int i = 1; i <= m; ++i) h[i] = 0;
    ans = 0;
    for (int i = a, cnt; i <= c; ++i) {
      sum = cnt = 0;
      st[++cnt] = b - 1;
      for (int j = b; j <= d; ++j) {
        if (map[i][j] == '1')
          h[j] = 0;
        else
          ++h[j];
        while (cnt && h[st[cnt]] >= h[j]) {
          sum -= h[st[cnt]] * (st[cnt] - st[cnt - 1]);
          --cnt;
        }
        st[++cnt] = j;
        sum += h[j] * (st[cnt] - st[cnt - 1]);
        ans += sum;
      }
    }
    printf("%d\n", ans);
  }
}
