#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int up[41][41], L[41][41], dp[41][41][41][41], grid[41][41];
int main() {
  int a, b, c, d, m, n, q, ans;
  char ch;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> ch;
      if (ch == '0')
        grid[i][j] = 0;
      else
        grid[i][j] = 1;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (grid[i][j] == 0) {
        L[i][j] = L[i][j - 1] + 1;
      }
    }
  }
  for (int j = 1; j <= m; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (grid[i][j] == 0) {
        up[i][j] = up[i - 1][j] + 1;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      for (int k = i; k <= n; ++k) {
        for (int l = j; l <= m; ++l) {
          int mnu = min(up[k][l], k - i + 1), mnl = min(l - j + 1, L[k][l]);
          for (int p = 1; p <= mnl; ++p) {
            mnu = min(up[k][l - p + 1], mnu);
            dp[i][j][k][l] += mnu;
          }
        }
      }
    }
  }
  while (q--) {
    cin >> a >> b >> c >> d;
    ans = 0;
    for (int i = a; i <= c; ++i) {
      for (int j = b; j <= d; ++j) {
        ans += dp[a][b][i][j];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
