#include <bits/stdc++.h>
using namespace std;
long long int ABS(long long int a) {
  if (a < 0) return (-a);
  return a;
}
void input() {}
inline void readInt(int &n) {
  n = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    n = n * 10 + ch - 48;
    ch = getchar();
  }
}
char s[55][55];
int cnt[55][55];
long long int dp[42][42][42][42];
long long int f(int a, int b, int c, int d) {
  if (a == c && b == d) {
    return (s[a][b] == '0');
  }
  long long int &res = dp[a][b][c][d];
  if (res != -1) return res;
  res = 0;
  if (b == d) {
    res = f(a, b, c - 1, d);
    if (s[c][d] == '0') {
      res++;
      for (int i = (c - 1); i >= (a); --i) {
        if (s[i][d] == '0')
          res++;
        else
          break;
      }
    }
    return res;
  }
  res = f(a, b, c, d - 1);
  res += f(a, d, c, d);
  stack<int> st, ans, when;
  int prev = a;
  for (int i = (a); i < (c + 1); ++i) {
    if (s[i][d] == '1') {
      prev = i + 1;
      while (st.size()) {
        st.pop();
        ans.pop();
      }
      continue;
    }
    int get = min(cnt[i][d - 1], d - b);
    while (st.size()) {
      int x = st.top();
      if (x > get) {
        st.pop();
        ans.pop();
        when.pop();
      } else
        break;
    }
    int last = (i - prev) * get;
    if (st.size()) {
      last = ans.top();
      last += (i - (when.top() + 1)) * get;
    }
    st.push(get);
    ans.push(last + get);
    when.push(i);
    res += (last + get);
  }
  return res;
}
int main() {
  input();
  int n, m, q;
  readInt(n);
  readInt(m);
  readInt(q);
  for (int i = (0); i < (n); ++i) scanf("%s", s[i]);
  for (int i = (0); i < (n); ++i) {
    cnt[i][0] = (s[i][0] == '0');
    for (int j = (1); j < (m); ++j) {
      if (s[i][j] == '1')
        cnt[i][j] = 0;
      else
        cnt[i][j] = (cnt[i][j - 1] + 1);
    }
  }
  memset(dp, -1, sizeof(dp));
  for (int i = (0); i < (q); ++i) {
    int a, b, c, d;
    readInt(a);
    readInt(b);
    readInt(c);
    readInt(d);
    printf("%lld\n", f(a - 1, b - 1, c - 1, d - 1));
  }
  return 0;
}
