#include <bits/stdc++.h>
using namespace std;
const int N = 1087, K = 31;
char g[N][N];
int s[N][N];
long long n[K], m[K];
long long qry(long long x, long long y, int b = 0, int u = 0, int l = 0,
              int k = K - 1) {
  if (x <= 0 || y <= 0) return 0;
  if (b) return x * y - qry(x, y, 0, u, l, k);
  if (k > 0 && n[k - 1] >= x && m[k - 1] >= y)
    return qry(x, y, u ^ l, u, l, k - 1);
  if (k == 0) {
    long long xl = 1, xr = x, yl = 1, yr = y;
    if (u) tie(xl, xr) = make_tuple(n[0] + 1 - xr, n[0] + 1 - xl);
    if (l) tie(yl, yr) = make_tuple(m[0] + 1 - yr, m[0] + 1 - yl);
    --xl, --yl;
    return s[xr][yr] - s[xl][yr] - s[xr][yl] + s[xl][yl];
  }
  if (x == n[k] || y == m[k]) return x * y / 2;
  if (x > n[k - 1]) {
    long long h = x - n[k - 1];
    return h * y + qry(n[k - 1] - h, y, 1, u ^ 1, l, k);
  }
  assert(y > m[k - 1]);
  long long w = y - m[k - 1];
  return x * w + qry(x, m[k - 1] - w, 1, u, l ^ 1, k);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n[0] >> m[0] >> q;
  for (int k = 1; k < K; ++k) {
    n[k] = n[k - 1] * 2;
    m[k] = m[k - 1] * 2;
  }
  for (int i = 1; i <= n[0]; ++i) {
    cin >> (g[i] + 1);
    for (int j = 1; j <= m[0]; ++j) {
      s[i][j] = g[i][j] - '0' + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  }
  while (q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    --x1, --y1;
    cout << qry(x2, y2) - qry(x1, y2) - qry(x2, y1) + qry(x1, y1) << '\n';
  }
}
