#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
long long c[1005][1005];
long long sum[1005][1005];
long long bitcnt(long long x) {
  long long res = 0;
  while (x) {
    if (x & 1) res++;
    x >>= 1;
  }
  return res;
}
bool rev(long long x, long long y) {
  return (bitcnt(x - 1) + bitcnt(y - 1)) & 1;
}
long long tann(long long x, long long y) {
  if (x == 0 || y == 0) return 0;
  long long res = 0, fx = (x + n - 1) / n, fy = (y + m - 1) / m;
  res += (fx - 1) * (fy - 1) / 2 * n * m;
  if (!(fx & 1) && !(fy & 1)) {
    if (rev(fx - 1, fy - 1))
      res += n * m - sum[n][m];
    else
      res += sum[n][m];
  }
  res += (fx - 1) / 2 * n * (y - (fy - 1) * m);
  if (!(fx & 1)) {
    if (rev(fx - 1, fy))
      res += n * (y - (fy - 1) * m) - sum[n][y - (fy - 1) * m];
    else
      res += sum[n][y - (fy - 1) * m];
  }
  res += (fy - 1) / 2 * (x - (fx - 1) * n) * m;
  if (!(fy & 1)) {
    if (rev(fx, fy - 1))
      res += (x - (fx - 1) * n) * m - sum[x - (fx - 1) * n][m];
    else
      res += sum[x - (fx - 1) * n][m];
  }
  if (rev(fx, fy))
    res += (x - (fx - 1) * n) * (y - (fy - 1) * m) -
           sum[x - (fx - 1) * n][y - (fy - 1) * m];
  else
    res += sum[x - (fx - 1) * n][y - (fy - 1) * m];
  return res;
}
int main() {
  scanf("%lld %lld %lld", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%1lld", &c[i][j]);
  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] + c[i][j];
  for (int i = 1; i <= q; i++) {
    long long x1, y1, x2, y2;
    scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
    printf("%lld\n", tann(x1 - 1, y1 - 1) + tann(x2, y2) - tann(x1 - 1, y2) -
                         tann(x2, y1 - 1));
  }
  return 0;
}
