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