#include <bits/stdc++.h>
using namespace std;
int s[41][41][41][41];
int r[41][41][41][41];
int b[41][41][41][41];
int a[41][41];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  bool flag = false;
  int n, m, q;
  cin >> n >> m >> q;
  char ch;
  getchar();
  for (int i1 = 1; i1 <= 40; i1++)
    for (int j1 = 1; j1 <= 40; j1++)
      for (int i2 = 1; i2 <= 40; i2++)
        for (int j2 = 1; j2 <= 40; j2++) {
          b[i1][j1][i2][j2] = -1;
        }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ch = getchar();
      a[i][j] = ch - '0';
    }
    getchar();
  }
  for (int i1 = 1; i1 <= n; i1++)
    for (int j1 = 1; j1 <= m; j1++)
      for (int i2 = 1; i2 <= n; i2++)
        for (int j2 = 1; j2 <= m; j2++) {
          if (i2 < i1 || j2 < j1) continue;
          r[i1][j1][i2][j2] =
              r[i1][j1][i2][j2 - 1] || r[i1][j1][i2 - 1][j2] || a[i2][j2];
        }
  for (int i1 = 1; i1 <= n; i1++)
    for (int j1 = 1; j1 <= m; j1++)
      for (int i2 = 1; i2 <= n; i2++)
        for (int j2 = 1; j2 <= m; j2++) {
          if (i2 < i1 || j2 < j1) continue;
          s[i1][j1][i2][j2] = s[i1][j1][i2 - 1][j2] + s[i1][j1][i2][j2 - 1] -
                              s[i1][j1][i2 - 1][j2 - 1] - r[i1][j1][i2][j2] + 1;
        }
  int sum, x1, y1, x2, y2;
  for (int i = 0; i < q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    if (b[x1][y1][x2][y2] != -1) {
      cout << b[x1][y1][x2][y2] << endl;
      continue;
    }
    sum = 0;
    for (int i = x1; i <= x2; i++)
      for (int j = y1; j <= y2; j++) sum += s[i][j][x2][y2];
    b[x1][y1][x2][y2] = sum;
    cout << sum << endl;
  }
}
