#include <bits/stdc++.h>
using namespace std;
const int Max = 50;
int row[Max][Max] = {0}, dp[Max][Max][Max][Max] = {0}, a[Max][Max];
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &a[i][j]);
      row[i][j] = row[i][j - 1] + 1;
      if (a[i][j] == 1) row[i][j] = 0;
    }
  }
  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++) {
          dp[i][j][k][l] =
              dp[i][j][k - 1][l] + dp[i][j][k][l - 1] - dp[i][j][k - 1][l - 1];
          int r = l - j + 1;
          for (int z = k; z >= i; z--) {
            r = min(r, row[z][l]);
            dp[i][j][k][l] += r;
          }
        }
      }
    }
  }
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    cout << dp[a][b][c][d] << endl;
  }
  return 0;
}
