#include <bits/stdc++.h>
using namespace std;
int dp[45][45][45][45] = {0};
int sumar[45][45] = {0};
int ar[45][45] = {0};
int check(int i, int j, int p, int q) {
  int s1 = sumar[p][q];
  int s2 = sumar[i - 1][q];
  int s3 = sumar[p][j - 1];
  int s4 = sumar[i - 1][j - 1];
  return ((s1 - s2 - s3 + s4) == 0);
}
int main() {
  int m, q, n;
  char ch;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    getchar();
    for (int j = 0; j < m; j++) {
      ch = getchar();
      ar[i][j] = ch - '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sumar[i][j] = sumar[i][j - 1] + sumar[i - 1][j] - sumar[i - 1][j - 1] +
                    ar[i - 1][j - 1];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int p = i; p <= n; p++) {
        for (int q = j; q <= m; q++) {
          dp[i][j][p][q] = dp[i][j][p - 1][q] + dp[i][j][p][q - 1] -
                           dp[i][j][p - 1][q - 1] + check(i, j, p, q);
        }
      }
    }
  }
  for (int p = n; p >= 1; p--) {
    for (int q = m; q >= 1; q--) {
      for (int i = p; i >= 1; i--) {
        for (int j = q; j >= 1; j--) {
          dp[i][j][p][q] +=
              dp[i + 1][j][p][q] + dp[i][j + 1][p][q] - dp[i + 1][j + 1][p][q];
        }
      }
    }
  }
  int a, b, c, d;
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    cout << dp[a][b][c][d] << "\n";
  }
  return 0;
}
