#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 7;
char s[maxn];
long long sum[maxn][maxn];
int n, m, q;
long long solve(long long x, long long y) {
  if (x <= 0 || y <= 0) return 0;
  long long tx = x % n, ty = y % m;
  long long ans = (x * y - tx * ty) / 2;
  if ((__builtin_popcount(x / n) + __builtin_popcount(y / m)) & 1) {
    ans += 1ll * (x % n) * (y % m) - sum[x % n][y % m];
  } else
    ans += sum[x % n][y % m];
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++) {
      sum[i][j] = (s[j] == '1');
      sum[i + n][j + m] = sum[i][j];
      sum[i + n][j] = sum[i][j + m] = sum[i][j] ^ 1;
    }
  }
  n *= 2, m *= 2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  }
  while (q--) {
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    printf("%lld\n", solve(x2, y2) - solve(x1 - 1, y2) - solve(x2, y1 - 1) +
                         solve(x1 - 1, y1 - 1));
  }
}
