#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
int n, m, q, a[maxn][maxn], s[maxn][maxn];
bool chk(int i, int j) { return __builtin_popcount(--i ^ --j) & 1 ? 1 : 0; }
long long Q(int x, int y) {
  if (x % n) {
    long long ans = Q(x / n * n, y) + 1LL * x % n * (y / m * m) / 2;
    if (y % m)
      ans +=
          (chk(x / n + 1, y / m + 1) ? 1LL * (x % n) * (y % m) - s[x % n][y % m]
                                     : s[x % n][y % m]);
    return ans;
  }
  if (y % m) {
    return Q(x, y / m * m) + 1LL * y % m * x / 2;
  }
  return 1LL * x * y / 2;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &a[i][j]);
      a[i + n][j + m] = a[i][j];
      a[i][j + m] = a[i + n][j] = a[i][j] ^ 1;
    }
  }
  n <<= 1, m <<= 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      s[i][j] = a[i][j] + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }
  }
  for (int i = 1, x1, y1, x2, y2; i <= q; i++) {
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    printf("%lld\n",
           Q(x2, y2) - Q(x1 - 1, y2) - Q(x2, y1 - 1) + Q(x1 - 1, y1 - 1));
  }
  return 0;
}
