#include <bits/stdc++.h>
using namespace std;
long long int ans[41][41][41][41];
char mat[41][41];
long long int psv[41][41], psh[41][41];
int main() {
  long long int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i < 1 + n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j < 1 + m; j++) mat[i][j] = s[j - 1];
  }
  for (int i = 1; i < 1 + n; i++) {
    for (int j = 1; j < 1 + m; j++) {
      if (j == 0) {
        if (mat[i][0] == '0') psh[i][0] = 1;
      } else if (mat[i][j] == '0')
        psh[i][j] = 1 + psh[i][j - 1];
    }
  }
  for (int j = 1; j < m + 1; j++) {
    for (int i = 1; i < 1 + n; i++)
      if (i == 0) {
        if (mat[i][j] == '0') psv[i][j] = 1;
      } else if (mat[i][j] == '0')
        psv[i][j] = psv[i - 1][j] + 1;
  }
  for (long long int i = 1; i < n + 1; i++) {
    for (long long int j = i; j < 1 + n; j++) {
      for (long long int k = 1; k < 1 + m; k++) {
        for (long long int l = k; l < 1 + m; l++) {
          if (mat[j][l] == '1') {
            ans[i][j][k][l] = ans[i][j][k][l - 1] + ans[i][j - 1][k][l] -
                              ans[i][j - 1][k][l - 1];
          } else {
            ans[i][j][k][l] = ans[i][j][k][l - 1] + ans[i][j - 1][k][l] -
                              ans[i][j - 1][k][l - 1];
            long long int p = 999999999;
            for (long long int z = j; z >= max(i, j - psv[j][l] + 1); z--) {
              p = min(p, psh[z][l]);
              p = min(p, l - k + 1);
              ans[i][j][k][l] += p;
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    long long int a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%lld\n", ans[a][c][b][d]);
  }
  return 0;
}
