#include <bits/stdc++.h>
using namespace std;
const int MAX = 50;
long long int dp1[MAX][MAX], dp2[MAX][MAX][MAX][MAX], dp3[MAX][MAX][MAX][MAX],
    t[MAX][MAX], zero[MAX][MAX];
char c[MAX][MAX];
int main() {
  long long int n, m, q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == '0')
        t[i][j] = 0;
      else
        t[i][j] = 1;
      int back = j;
      while (back >= 1 and t[i][back] == 0) {
        zero[i][j]++;
        back--;
      }
    }
  }
  dp1[1][1] = t[1][1];
  for (int i = 1; i <= m; i++) {
    dp1[1][i] = dp1[1][i - 1] + t[1][i];
  }
  for (int i = 1; i <= n; i++) {
    dp1[i][1] = dp1[i - 1][1] + t[i][1];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= m; j++) {
      dp1[i][j] = dp1[i - 1][j] + dp1[i][j - 1] - dp1[i - 1][j - 1] + t[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = i; k <= n; k++) {
        for (int p = j; p <= m; p++) {
          dp2[i][j][k][p] = dp1[k][p] - dp1[i - 1][p] - dp1[k][j - 1];
          if (i - 1 == 0 or j - 1 == 0) {
            dp2[i][j][k][p] += 0;
          } else {
            dp2[i][j][k][p] += t[1][1];
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      for (int k = i; k <= n; k++) {
        for (int p = j; p <= m; p++) {
          dp3[i][j][k][p] = dp3[i][j][k - 1][p] + dp3[i][j][k][p - 1] -
                            dp3[i][j][k - 1][p - 1];
          long long int maxi = p - j + 1;
          for (int cur = k; cur >= i; cur--) {
            maxi = min(zero[cur][p], maxi);
            dp3[i][j][k][p] = dp3[i][j][k][p] + maxi;
          }
        }
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << dp3[a][b][c][d] << endl;
  }
}
