#include <bits/stdc++.h>
using namespace std;
template <class T>
typename T::value_type arr_sum(const T& v, int n) {
  typename T::value_type sum = 0;
  for (int i = 0; i < n; ++i) sum += v[i];
  return sum;
}
struct Sync_stdio {
  Sync_stdio() { ios_base::sync_with_stdio(false); }
} _sync_stdio;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<string> v(n + 1);
  int a[n + 1][m + 1][n + 1][m + 1];
  int s[n + 1][m + 1][n + 1][m + 1];
  int res[n + 1][m + 1][n + 1][m + 1];
  memset(a, 0, sizeof(a));
  memset(s, 0, sizeof(s));
  memset(res, 0, sizeof(s));
  string ts;
  for (int i = 0; i < m + 1; ++i) {
    ts += '0';
  }
  v.push_back(ts);
  for (int i = 1; i < n + 1; ++i) {
    cin >> v[i];
    v[i] = '0' + v[i];
  }
  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) {
            a[i][j][k][l] = v[k][l] == '0';
          } else if (i == k) {
            a[i][j][k][l] = v[k][l] == '0' && a[i][j][k][l - 1] == 1;
          } else if (j == l) {
            a[i][j][k][l] = v[k][l] == '0' && a[i][j][k - 1][l] == 1;
          } else {
            a[i][j][k][l] = v[k][l] == '0' && a[i][j][k - 1][l] == 1 &&
                            a[i][j][k][l - 1] == 1;
          }
        }
      }
    }
  }
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < m + 1; ++j) {
      for (int k = 1; k < n + 1; ++k) {
        for (int l = 1; l < m + 1; ++l) {
          s[i][j][k][l] =
              s[i][j][k][l - 1] + s[i][j][k - 1][l] + s[i][j - 1][k][l] +
              s[i - 1][j][k][l] - s[i][j][k - 1][l - 1] -
              s[i][j - 1][k][l - 1] - s[i][j - 1][k - 1][l] -
              s[i - 1][j][k][l - 1] - s[i - 1][j][k - 1][l] -
              s[i - 1][j - 1][k][l] + s[i][j - 1][k - 1][l - 1] +
              s[i - 1][j][k - 1][l - 1] + s[i - 1][j - 1][k][l - 1] +
              s[i - 1][j - 1][k - 1][l] - s[i - 1][j - 1][k - 1][l - 1] +
              a[i][j][k][l];
        }
      }
    }
  }
  for (int i = 1; i < n + 1; ++i) {
    for (int j = 1; j < m + 1; ++j) {
      for (int k = 1; k < n + 1; ++k) {
        for (int l = 1; l < m + 1; ++l) {
          res[i][j][k][l] =
              s[k][l][k][l] - s[k][l][k][j - 1] - s[k][l][i - 1][l] -
              s[k][j - 1][k][l] - s[i - 1][l][k][l] + s[k][l][i - 1][j - 1] +
              s[k][j - 1][k][j - 1] + s[k][j - 1][i - 1][l] +
              s[i - 1][l][k][j - 1] + s[i - 1][l][i - 1][l] +
              s[i - 1][j - 1][k][l] - s[k][j - 1][i - 1][j - 1] -
              s[i - 1][l][i - 1][j - 1] - s[i - 1][j - 1][k][j - 1] -
              s[i - 1][j - 1][i - 1][l] + s[i - 1][j - 1][i - 1][j - 1];
        }
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << res[x1][y1][x2][y2] << endl;
  }
}
