#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
long long int A[MAXN][MAXN] = {0};
long long int N, M;
inline long long int get_sum(long long int x, long long int y) {
  return A[x][y];
}
inline long long int get_inv_sum(long long int x, long long int y) {
  return x * y - A[x][y];
}
long long int solve(long long int inverted, long long int x, long long int y) {
  if (x <= 0 || y <= 0) return 0;
  if (x <= N && y <= M) {
    if (inverted) {
      return get_inv_sum(x, y);
    } else {
      return get_sum(x, y);
    }
  }
  if (y > M) {
    if (y % M == 0) {
      long long int coef = y / M;
      if ((coef & (coef - 1)) == 0) {
        return x * (y / 2);
      }
    }
    long long int p1 = 1;
    while (p1 * M * 2 < y) {
      p1 *= 2;
    }
    long long int ans = solve(inverted, x, p1 * M);
    long long int baki = solve(!inverted, x, y - p1 * M);
    return ans + baki;
  }
  if (x % N == 0) {
    long long int coef = x / N;
    if ((coef & (coef - 1)) == 0) {
      return (x / 2) * y;
    }
  }
  long long int p1 = 1;
  while (p1 * N * 2 < x) {
    p1 *= 2;
  }
  long long int ans = solve(inverted, p1 * N, y);
  long long int baki = solve(!inverted, x - p1 * N, y);
  return ans + baki;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int Q;
  cin >> N >> M >> Q;
  char x;
  for (long long int i = 1; i <= N; i++) {
    for (long long int j = 1; j <= M; j++) {
      cin >> x;
      A[i][j] = x - '0';
    }
  }
  for (long long int i = 1; i <= N; i++) {
    A[i][1] += A[i - 1][1];
  }
  for (long long int j = 1; j <= M; j++) {
    A[1][j] += A[1][j - 1];
  }
  for (long long int i = 2; i <= N; i++) {
    for (long long int j = 2; j <= M; j++) {
      A[i][j] += A[i - 1][j] + A[i][j - 1] - A[i - 1][j - 1];
    }
  }
  long long int x1, x2, y1, y2;
  while (Q--) {
    cin >> x1 >> y1 >> x2 >> y2;
    long long int ans = solve(0, x2, y2) + solve(0, x1 - 1, y1 - 1) -
                        solve(0, x1 - 1, y2) - solve(0, x2, y1 - 1);
    cout << ans << endl;
  }
}
