#include <bits/stdc++.h>
using namespace std;
int dp[45][45][45][45];
int a[45][45];
int n, m, q;
string s;
int main() {
  cin >> n >> m >> q;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; i++) {
    cin >> s;
    a[i][0] = (s[0] == '0');
    for (int j = 1; j < m; j++) {
      if (s[j] == '0')
        a[i][j] = 1 + a[i][j - 1];
      else
        a[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int x = i; x < n; x++)
        for (int y = j; y < m; y++) {
          if (x > i) dp[i][j][x][y] += dp[i][j][x - 1][y];
          if (y > j) dp[i][j][x][y] += dp[i][j][x][y - 1];
          if (x > i && y > j) dp[i][j][x][y] -= dp[i][j][x - 1][y - 1];
          int tmp = min(a[x][y], y - j + 1);
          for (int k = x; k >= i; k--) {
            tmp = min(a[k][y], tmp);
            dp[i][j][x][y] += tmp;
          }
        }
  while (q--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << dp[a - 1][b - 1][c - 1][d - 1] << endl;
  }
}
