#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
int a[45][45];
int q[45][45];
int g[45][45][45][45];
int ans[45][45][45][45];
inline int READ() {
  char c = '!';
  while (c < '0' || c > '9') {
    c = getchar();
  }
  int res = c - '0';
  c = getchar();
  while (c >= '0' && c <= '9') {
    res = res * 10 + (int)(c - '0');
    c = getchar();
  }
  return res;
}
inline bool GOOD(int i, int j, int k, int l) {
  return (q[k][l] - q[k][j - 1] - q[i - 1][l] + q[i - 1][j - 1] == 0);
}
int main() {
  ios::sync_with_stdio(false);
  N = READ();
  M = READ();
  Q = READ();
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      char tmp = getchar();
      while (tmp != '0' && tmp != '1') tmp = getchar();
      a[i][j] = tmp - '0';
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      q[i][j] = a[i][j] + q[i - 1][j] + q[i][j - 1] - q[i - 1][j - 1];
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= M; j++) {
      for (int k = i; k <= N; k++) {
        for (int l = j; l <= M; l++) {
          ans[i][j][k][l] = ans[i][j][k - 1][l] + ans[i][j][k][l - 1] -
                            ans[i][j][k - 1][l - 1] + GOOD(i, j, k, l);
        }
      }
    }
  }
  for (int T = 1; T <= Q; T++) {
    int a, b, c, d;
    a = READ();
    b = READ();
    c = READ();
    d = READ();
    int res = 0;
    for (int i = a; i <= c; i++) {
      for (int j = b; j <= d; j++) {
        res += ans[i][j][c][d];
      }
    }
    cout << res << endl;
  }
  return 0;
}
