#include <bits/stdc++.h>
using namespace std;
const int inf = 400000;
const int maxn = 41;
int n, m, q, p[maxn][maxn], mn, d[maxn][maxn][maxn][maxn],
    dp[maxn][maxn][maxn][maxn];
char a[maxn][maxn];
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", &a[i][j]);
    scanf("%c", &a[i][0]);
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      if (a[i][j] == '0') p[i][j] = p[i - 1][j] + 1;
    }
  for (int i1 = 1; i1 <= n; ++i1)
    for (int i2 = i1; i2 <= n; ++i2)
      for (int j2 = 1; j2 <= m; ++j2) {
        mn = i2 - i1 + 1;
        for (int j1 = j2; j1 >= 1; --j1) {
          mn = min(mn, p[i2][j1]);
          d[i1][i2][j1][j2] = d[i1][i2][j1 + 1][j2] + mn;
        }
      }
  for (int i1 = 1; i1 <= n; ++i1)
    for (int i2 = i1; i2 <= n; ++i2)
      for (int j1 = 1; j1 <= m; ++j1)
        for (int j2 = j1; j2 <= m; ++j2) {
          dp[i1][i2][j1][j2] = dp[i1][i2 - 1][j1][j2];
          for (int j3 = j1; j3 <= j2; ++j3)
            dp[i1][i2][j1][j2] += d[i1][i2][j1][j3];
        }
  int i1, i2, j1, j2;
  for (int i = 0; i < q; ++i) {
    scanf("%d%d%d%d", &i1, &j1, &i2, &j2);
    printf("%d\n", dp[i1][i2][j1][j2]);
  }
  return 0;
}
