#include <bits/stdc++.h>
using namespace std;
int dp[42][42][42][42];
int endat[42][42];
int row[42][42];
int main() {
  int t = 1;
  while (t--) {
    int n, m, q;
    cin >> n >> m >> q;
    char x;
    int a[n + 2][m + 2];
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        cin >> x;
        a[i][j] = x - '0';
      }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (a[i][j] == 1)
          row[i][j] = 0;
        else
          row[i][j] = row[i][j - 1] + 1;
      }
    }
    for (int a = 1; a <= n; a++) {
      for (int b = 1; b <= m; b++) {
        for (int c = a; c <= n; c++) {
          for (int d = b; d <= m; d++) {
            if (a == c && b == d) {
            }
            int& ans = dp[a][b][c][d] = dp[a][b][c][d - 1] +
                                        dp[a][b][c - 1][d] -
                                        dp[a][b][c - 1][d - 1];
            int more = d - b + 1;
            for (int e = c; e >= a; e--) {
              more = min(more, row[e][d]);
              ans += more;
            }
          }
        }
      }
    }
    int l, r, e, f;
    while (q--) {
      cin >> l >> r >> e >> f;
      cout << dp[l][r][e][f] << endl;
    }
  }
}
