#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e3 + 10;
const long long Inf = LONG_LONG_MAX >> 2;
const int Log = 20;
const long long Mod = 10321;
char c[Maxn][Maxn];
long long A[Maxn][Maxn];
long long ps[Maxn][Maxn];
long long n, m, second, Sp;
long long state(long long x, long long y) {
  return (__builtin_popcountll(x - 1) + __builtin_popcountll(y - 1)) % 2;
}
long long get(long long x, long long y) {
  if (min(x, y) == 0) return 0;
  long long A = x / n;
  long long B = y / m;
  long long a = x % n;
  long long b = y % m;
  long long ans = n * m * ((A * B) / 2LL);
  if (((A % 2) == 1) && ((B % 2) == 1)) {
    ans += (state(A, B) == 0 ? second : Sp);
  }
  if (a) {
    if (B % 2 == 0) {
      ans += (a * (B * m) / 2LL);
    } else {
      ans += (a * ((B / 2) * m));
      long long st = state(A + 1, B);
      ans += (st == 0 ? ps[a][m] : a * m - ps[a][m]);
    }
  }
  if (b) {
    if (A % 2 == 0) {
      ans += (b * (A * n) / 2LL);
    } else {
      ans += (b * ((A / 2) * n));
      long long st = state(A, B + 1);
      ans += (st == 0 ? ps[n][b] : b * n - ps[n][b]);
    }
  }
  if ((a > 0) and (b > 0)) {
    long long st = state(A + 1, B + 1);
    ans += (st == 0 ? ps[a][b] : a * b - ps[a][b]);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      A[i][j] = c[i][j] - '0';
      ps[i][j] = A[i][j] + ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1];
    }
  }
  second = ps[n][m];
  Sp = (n * m) - second;
  long long x1, y1, x2, y2;
  for (int i = 1; i <= q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << get(x2, y2) - get(x2, y1 - 1) - get(x1 - 1, y2) +
                get(x1 - 1, y1 - 1)
         << '\n';
  }
  return 0;
}
