#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int board[45][45];
string s;
int a, b, c, d;
int memo[45][45][45][45];
int sum[45][45];
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i < (n + 1); i++) {
    cin >> s;
    for (int j = 1; j < (m + 1); j++) {
      if (s[j - 1] == '1') {
        board[i][j] = 1;
      } else {
        board[i][j] = 0;
      }
    }
  }
  for (int x1 = 1; x1 < (n + 1); x1++) {
    for (int y1 = 1; y1 < (m + 1); y1++) {
      for (int i = x1; i < (n + 1); i++) {
        for (int j = y1; j < (m + 1); j++) {
          sum[i][j] = 0;
        }
      }
      for (int i = x1; i < (n + 1); i++) {
        for (int j = y1; j < (m + 1); j++) {
          if (board[i][j] == 1) {
            break;
          }
          if (i > x1 && sum[i - 1][j] == 0) {
            break;
          }
          sum[i][j] = 1;
        }
      }
      for (int i = x1; i < (n + 1); i++) {
        for (int j = y1 + 1; j < (m + 1); j++) {
          sum[i][j] += sum[i][j - 1];
        }
      }
      for (int i = x1 + 1; i < (n + 1); i++) {
        for (int j = y1; j < (m + 1); j++) {
          sum[i][j] += sum[i - 1][j];
        }
      }
      for (int i = 0; i < (x1 + 1); i++) {
        for (int j = 0; j < (y1 + 1); j++) {
          for (int k = x1; k < (n + 1); k++) {
            for (int l = y1; l < (m + 1); l++) {
              memo[i][j][k][l] += sum[k][l];
            }
          }
        }
      }
    }
  }
  for (int i = 0; i < (q); i++) {
    cin >> a >> b >> c >> d;
    cout << memo[a][b][c][d] << "\n";
  }
  return 0;
}
