#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
int f[45][45][45][45], up[45][45];
char ch[45][45];
int main() {
  int n, m, cao;
  cin >> n >> m >> cao;
  memset(up, 0, sizeof(up));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> ch[i][j];
      if (ch[i][j] == '0')
        up[i][j] = up[i - 1][j] + 1;
      else
        up[i][j] = 0;
    }
  memset(f, 0, sizeof(f));
  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++) {
          f[i][j][k][l] =
              f[i][j][k - 1][l] + f[i][j][k][l - 1] - f[i][j][k - 1][l - 1];
          int minn = min(k - i + 1, up[k][l]);
          for (int o = l; o >= j; o--) {
            if (up[k][o] < minn) minn = up[k][o];
            if (minn == 0) break;
            f[i][j][k][l] += minn;
          }
        }
  while (cao--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << f[a][b][c][d] << endl;
  }
}
