#include <bits/stdc++.h>
using namespace std;
int grid[50][50], ile[50][50][50][50], lewo[50][50];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == '0')
        grid[i][j + 1] = 0;
      else
        grid[i][j + 1] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (grid[i][j] == 1)
        lewo[i][j] = 0;
      else
        lewo[i][j] = lewo[i][j - 1] + 1;
    }
  }
  for (int a = 1; a <= n; a++) {
    for (int b = 1; b <= m; b++) {
      for (int i = a; i <= n; i++) {
        for (int j = b; j <= m; j++) {
          if (grid[i][j] == 1) {
            ile[i][j][a][b] = ile[i - 1][j][a][b] + ile[i][j - 1][a][b] -
                              ile[i - 1][j - 1][a][b];
          } else {
            ile[i][j][a][b] = ile[i - 1][j][a][b] + ile[i][j - 1][a][b] -
                              ile[i - 1][j - 1][a][b];
            int blokada = lewo[i][j];
            for (int k = i; k >= a; k--) {
              if (grid[k][j] == 1) break;
              ile[i][j][a][b] += min(blokada, min(lewo[k][j], j - b + 1));
              blokada = min(blokada, lewo[k][j]);
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    int wynik = ile[c][d][a][b];
    printf("%d\n", wynik);
  }
  return 0;
}
