#include <bits/stdc++.h>
using namespace std;
long long h, w, Q;
long long a[2005][2005];
long long sum[2005][2005];
long long rect(long long sx, long long sy, long long tx, long long ty) {
  if (sx > tx || sy > ty) return 0;
  return sum[tx][ty] - sum[sx - 1][ty] - sum[tx][sy - 1] + sum[sx - 1][sy - 1];
}
long long get(long long x, long long y) {
  long long ret = 0;
  for (; x; x /= 2) ret += x & 1;
  for (; y; y /= 2) ret += y & 1;
  return ret % 2;
}
long long calc(long long y, long long x) {
  if (y <= 0 || x <= 0) return 0;
  long long X = x / w, Y = y / h;
  long long ret = (X / 2 * 2) * (Y / 2 * 2) / 2 * h * w;
  long long remx = x % (2 * w), remy = y % (2 * h);
  ret += rect(1, 1, remx, 2 * h) * (Y / 2);
  ret += rect(1, 1, 2 * w, remy) * (X / 2);
  if (get((x + 2 * w - 1) / (2 * w) - 1, (y + 2 * h - 1) / (2 * h) - 1) == 0)
    ret += rect(1, 1, remx, remy);
  else
    ret += remx * remy - rect(1, 1, remx, remy);
  return ret;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> h >> w >> Q;
  char c;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      cin >> c;
      a[j][i] = c - '0';
    }
  }
  for (int y = 1; y <= 2 * h; y++) {
    for (int x = 1; x <= 2 * w; x++) {
      a[x][y] = a[(x - 1) % w + 1][(y - 1) % h + 1];
      if ((x - 1) / w + (y - 1) / h == 1) a[x][y] = 1 - a[x][y];
    }
  }
  for (int y = 1; y <= 2 * h; y++) {
    for (int x = 1; x <= 2 * w; x++) {
      sum[x][y] = a[x][y] + sum[x - 1][y] + sum[x][y - 1] - sum[x - 1][y - 1];
    }
  }
  long long sx, sy, tx, ty;
  for (int q = 0; q < Q; q++) {
    cin >> sx >> sy >> tx >> ty;
    long long ans = calc(tx, ty);
    ans -= calc(sx - 1, ty);
    ans -= calc(tx, sy - 1);
    ans += calc(sx - 1, sy - 1);
    cout << ans << "\n";
  }
  return 0;
}
