#include <bits/stdc++.h>
const int MOD = 1000000007;
int arr[45][45];
bool isr[45][45][45][45];
int cnt[45][45];
int dp[45][45][45][45];
using namespace std;
int n, m, q;
bool inbound(int i, int j, int k, int l) {
  return (1 <= i && i <= n && 1 <= k && k <= n && 1 <= j && j <= m && 1 <= l &&
          l <= m && i <= k && j <= l);
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char k;
      scanf(" %c", &k);
      if (k == '0') {
        arr[i + 1][j + 1] = 0;
      } else {
        arr[i + 1][j + 1] = 1;
      }
    }
  }
  memset(isr, true, sizeof isr);
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < m + 1; j++) {
      for (int k = i; k < n + 1; k++) {
        for (int l = j; l < m + 1; l++) {
          if (i == k && j == l && arr[i][j] == 1) {
            isr[i][j][k][l] = false;
            continue;
          }
          if (arr[k][l] == 1) {
            isr[i][j][k][l] = false;
            continue;
          }
          isr[i][j][k][l] = isr[i][j][k][l - 1] & isr[i][j][k - 1][l];
        }
      }
    }
  }
  for (int i = n; i >= 1; i--) {
    for (int j = m; j >= 1; j--) {
      for (int k = i; k <= n; k++) {
        for (int l = j; l <= m; l++) {
          if (!inbound(i, j, k, l)) {
            continue;
          }
          if (isr[i][j][k][l]) {
            dp[i][j][k][l] = 1;
          }
          dp[i][j][k][l] +=
              dp[i + 1][j][k][l] + dp[i][j + 1][k][l] + dp[i][j][k - 1][l] +
              dp[i][j][k][l - 1] - dp[i + 1][j + 1][k][l] -
              dp[i + 1][j][k - 1][l] - dp[i + 1][j][k][l - 1] -
              dp[i][j + 1][k - 1][l] - dp[i][j + 1][k][l - 1] -
              dp[i][j][k - 1][l - 1] + dp[i][j + 1][k - 1][l - 1] +
              dp[i + 1][j + 1][k][l - 1] + dp[i + 1][j][k - 1][l - 1] +
              dp[i + 1][j + 1][k - 1][l] - dp[i + 1][j + 1][k - 1][l - 1];
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int q1, q2, q3, q4;
    scanf("%d %d %d %d", &q1, &q2, &q3, &q4);
    cout << dp[q1][q2][q3][q4] << endl;
  }
}
