#include <bits/stdc++.h>
using namespace std;
int dp1[41][41];
int dp3[41][41][41][41];
int dp4[41][41][41][41];
int b[41][41][41][41];
int a[41][41];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char ch = getchar();
      while (ch != '0' && ch != '1') ch = getchar();
      a[i][j] = (ch == '0');
    }
  }
  for (int i = 1; i <= n; i++) {
    int t = 0;
    for (int j = 1; j <= m; j++) {
      t += a[i][j];
      dp1[i][j] = dp1[i - 1][j] + t;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int i1 = 1; i1 <= i; i1++) {
        int k = 0;
        for (int j1 = 1; j1 <= j; j1++) {
          int t =
              dp1[i][j] - dp1[i1 - 1][j] - dp1[i][j1 - 1] + dp1[i1 - 1][j1 - 1];
          int need = (j - j1 + 1) * (i - i1 + 1);
          if (t == need) k++;
          dp3[i][j][i1][j1] = dp3[i][j][i1 - 1][j1] + k;
        }
      }
  for (int z = 1; z <= q; z++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    if (b[x1][y1][x2][y2] == false) {
      int ans = 0;
      for (int i = x1; i <= x2; i++)
        for (int j = y1; j <= y2; j++) {
          ans += dp3[i][j][i][j] - dp3[i][j][x1 - 1][j] - dp3[i][j][i][y1 - 1] +
                 dp3[i][j][x1 - 1][y1 - 1];
        }
      dp4[x1][y1][x2][y2] = ans;
      b[x1][y1][x2][y2] = true;
    }
    printf("%d\n", dp4[x1][y1][x2][y2]);
  }
}
