#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int n, m, q, sum[N + 5][N + 5];
int side(int x, int y) {
  int res = 0;
  while (x) {
    res += (x & 1);
    x >>= 1;
  }
  while (y) {
    res += (y & 1);
    y >>= 1;
  }
  return res & 1;
}
long long single(const int x, const int y, const int builtin_) {
  return builtin_ & 1 ? x * y - sum[x][y] : sum[x][y];
}
long long Block(const int x, const int y, const int r, const int c) {
  long long ans = 1ll * r * c / 2 * n * m;
  if ((r & 1) && (c & 1)) ans += single(n, m, side(r - 1, c - 1));
  return ans;
}
long long Row(const int x, const int y, const int r, const int c) {
  int xx = r * n;
  long long ans = 1ll * c / 2 * (x - xx) * m;
  if (c & 1) ans += single(x - xx, m, side(r, c - 1));
  return ans;
}
long long Col(const int x, const int y, const int r, const int c) {
  int yy = c * m;
  long long ans = 1ll * r / 2 * (y - yy) * n;
  if (r & 1) ans += single(n, y - yy, side(r - 1, c));
  return ans;
}
long long Rest(const int x, const int y, const int r, const int c) {
  int xx = r * n, yy = c * m;
  return single(x - xx, y - yy, side(r, c));
}
long long query(const int x, const int y) {
  if (x == 0 || y == 0) return 0;
  int r = (x - 1) / n, c = (y - 1) / m;
  if (r == 0 && c == 0) return Rest(x, y, r, c);
  if (r == 0) return Row(x, y, r, c) + Rest(x, y, r, c);
  if (c == 0) return Col(x, y, r, c) + Rest(x, y, r, c);
  return Block(x, y, r, c) + Row(x, y, r, c) + Col(x, y, r, c) +
         Rest(x, y, r, c);
}
long long sovle(const int x1, const int y1, const int x2, const int y2) {
  return query(x2, y2) - query(x1 - 1, y2) - query(x2, y1 - 1) +
         query(x1 - 1, y1 - 1);
}
void init() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      int x;
      scanf("%1d", &x);
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + x;
    }
  }
  for (int i = 1; i <= q; ++i) {
    int x1, x2, y1, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    long long ans = sovle(x1, y1, x2, y2);
    printf("%lld\n", ans);
  }
}
int main() {
  init();
  return 0;
}
