#include <bits/stdc++.h>
using namespace std;
int n, m, q, i, j, g[100][100] = {0};
string s[100];
int res[43][43][43][43] = {0};
int main() {
  cin >> n >> m >> q;
  for (i = 0; i < n; i++) {
    cin >> s[i];
    for (j = 0; j < m; j++) g[i + 1][j + 1] = s[i][j] - '0';
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      g[i][j] = g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1] + (g[i][j] == 1);
    }
  }
  int x, y;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      int v[43][43] = {0};
      for (x = i; x >= 1; x--) {
        for (y = j; y >= 1; y--) {
          v[x][y] =
              v[x + 1][y] + v[x][y + 1] - v[x + 1][y + 1] +
              (g[i][j] - g[x - 1][j] - g[i][y - 1] + g[x - 1][y - 1] == 0);
          res[x][y][i][j] = res[x][y][i - 1][j] + res[x][y][i][j - 1] -
                            res[x][y][i - 1][j - 1] + v[x][y];
        }
      }
    }
  }
  int loop;
  for (loop = 0; loop < q; loop++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << res[a][b][c][d] << endl;
  }
  return 0;
}
