#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long Bpow(long long a, long long s) {
  if (s == 0) {
    return 1;
  }
  long long u = Bpow(a, s / 2);
  if (s & 1)
    return u * u % mod * a % mod;
  else
    return u * u % mod;
}
long long n, m, q;
vector<vector<long long>> a(1001, vector<long long>(1001));
long long S(long long c, long long p) {
  while (c << 1 <= p) c <<= 1;
  return c;
}
long long F(long long x, long long y) {
  if (!x || !y) return 0;
  if (x > n) {
    long long left = S(n, x);
    if (left == x) return left * y / 2;
    return F(left, y) + (x - left) * y - F(x - left, y);
  }
  if (y > m) {
    long long left = S(m, y);
    if (left == y) return left * x / 2;
    return F(x, left) + (y - left) * x - F(x, y - left);
  }
  return a[x][y];
}
int32_t main() {
  cin >> n >> m >> q;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j < m + 1; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
    }
  }
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      a[i][j] += a[i][j - 1];
    }
  }
  for (long long i = 1; i < n + 1; i++) {
    for (long long j = 1; j < m + 1; j++) {
      a[i][j] += a[i - 1][j];
    }
  }
  while (q--) {
    long long x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << F(x2, y2) - F(x2, y1 - 1) - F(x1 - 1, y2) + F(x1 - 1, y1 - 1)
         << "\n";
  }
}
