#include <bits/stdc++.h>
using namespace std;
const int N = 42;
char arr[N][N];
int mxh[N][N];
int dp[N][N][N][N];
int sm[N][N][N][N];
int n, m, q;
void calc_mxh() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (arr[i][j] == '0') {
        if (i == 0) continue;
        if (arr[i - 1][j] == '1')
          mxh[i][j] = i;
        else
          mxh[i][j] = mxh[i - 1][j];
      }
}
void calc_dp() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == '0')
        for (int h = 0; h < i + 1; h++) {
          int sum = 0;
          int up = h;
          for (int k = j; k >= 0; k--) {
            if (arr[i][k] == '1') up = i + 1;
            up = max(mxh[i][k], up);
            sum += (i - up + 1);
            dp[i][j][h][k] = sum;
          }
        }
    }
}
void calc_sm() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int h = 0; h < i + 1; h++)
        for (int k = 0; k < j + 1; k++) {
          sm[i][j][h][k] = dp[i][j][h][k];
          if (i) sm[i][j][h][k] += sm[i - 1][j][h][k];
          if (j) sm[i][j][h][k] += sm[i][j - 1][h][k];
          if (i && j) sm[i][j][h][k] -= sm[i - 1][j - 1][h][k];
        }
}
void pre() {
  calc_mxh();
  calc_dp();
  calc_sm();
}
int get_ans(int x0, int y0, int x1, int y1) {
  int h = x0, k = y0;
  return sm[x1][y1][h][k];
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  pre();
  while (q--) {
    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    cout << get_ans(x0 - 1, y0 - 1, x1 - 1, y1 - 1) << endl;
  }
  return 0;
}
