#include <bits/stdc++.h>
using namespace std;
int n, m, q;
char str[100];
int a[50][50], s[50][50], b[50][50][50], c[50][50][50], d[50][50][50];
int main() {
  memset(s, 0, sizeof(s));
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%s", str);
    for (int j = 0; j < m; ++j) {
      a[i + 1][j + 1] = str[j] - '0';
      s[i + 1][j + 1] = s[i][j + 1] + a[i + 1][j + 1];
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = i; j <= n; ++j) {
      for (int k = 1; k <= m; ++k) {
        if (s[j][k] - s[i - 1][k] == 0) {
          c[i][j][k] = c[i][j][k - 1] + 1;
          b[i][j][k] = b[i][j][k - 1] + c[i][j][k];
        } else {
          c[i][j][k] = 0;
          b[i][j][k] = b[i][j][k - 1];
        }
      }
      for (int k = 1; k <= m; ++k) {
        int tt;
        for (tt = k; tt <= m; ++tt)
          if (s[j][tt] - s[i - 1][tt] != 0) break;
        d[i][j][k] = tt;
      }
    }
  while (q--) {
    int x1, y1, x2, y2, ans = 0;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    for (int i = x1; i <= x2; ++i)
      for (int j = i; j <= x2; ++j)
        ans += b[i][j][y2] - b[i][j][y1 - 1] -
               c[i][j][y1 - 1] *
                   (d[i][j][y1] > y2 + 1 ? (y2 + 1 - y1) : (d[i][j][y1] - y1));
    printf("%d\n", ans);
  }
  return 0;
}
