#include <bits/stdc++.h>
const int N = 1010;
long long n, m, q, a[N][N], fr[N][N];
int cnt(long long x) {
  int res = 0;
  while (x) {
    if (x & 1) res++;
    x >>= 1;
  }
  return res;
}
long long sum(long long x, long long y) {
  if (!x || !y) return 0;
  long long res = 0, x_ = (x + n - 1) / n, y_ = (y + m - 1) / m;
  res += (x_ - 1) * (y_ - 1) / 2 * n * m;
  if (!(x_ & 1 || y_ & 1)) {
    if (cnt(x_ - 2) + cnt(y_ - 2) & 1)
      res += n * m - fr[n][m];
    else
      res += fr[n][m];
  }
  res += ((x_ - 1) >> 1) * n * (y - (y_ - 1) * m);
  if (!(x_ & 1)) {
    if (cnt(x_ - 2) + cnt(y_ - 1) & 1)
      res += n * (y - (y_ - 1) * m) - fr[n][y - (y_ - 1) * m];
    else
      res += fr[n][y - (y_ - 1) * m];
  }
  res += ((y_ - 1) >> 1) * (x - (x_ - 1) * n) * m;
  if (!(y_ & 1)) {
    if (cnt(x_ - 1) + cnt(y_ - 2) & 1)
      res += (x - (x_ - 1) * n) * m - fr[x - (x_ - 1) * n][m];
    else
      res += fr[x - (x_ - 1) * n][m];
  }
  if (cnt(x_ - 1) + cnt(y_ - 1) & 1)
    res += (x - (x_ - 1) * n) * (y - (y_ - 1) * m) -
           fr[x - (x_ - 1) * n][y - (y_ - 1) * m];
  else
    res += fr[x - (x_ - 1) * n][y - (y_ - 1) * m];
  return res;
}
int main() {
  register int i, j;
  register long long t1, t2, t3, t4;
  register char ch;
  scanf("%lld%lld%lld", &n, &m, &q);
  for (i = (1); i <= (n); i++)
    for (j = (1); j <= (m); j++) scanf(" %c", &ch), a[i][j] = ch ^ 48;
  for (i = (1); i <= (n); i++)
    for (j = (1); j <= (m); j++)
      fr[i][j] = a[i][j] + fr[i - 1][j] + fr[i][j - 1] - fr[i - 1][j - 1];
  while (q--) {
    scanf("%lld%lld%lld%lld", &t1, &t2, &t3, &t4);
    printf("%lld\n", sum(t3, t4) - sum(t1 - 1, t4) - sum(t3, t2 - 1) +
                         sum(t1 - 1, t2 - 1));
  }
  return 0;
}
