#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int sum[1005][1005];
int check(int r, int c) {
  return (__builtin_popcount(r) + __builtin_popcount(c)) & 1;
}
int fuck(int x, int y, int o) {
  if (o == 0) {
    return sum[x][y];
  } else {
    return x * y - sum[x][y];
  }
}
long long A(int x, int y, int r, int c) {
  long long ans = 1LL * r * c / 2 * n * m;
  if ((r & 1) && (c & 1)) {
    ans += fuck(n, m, check(r - 1, c - 1));
  }
  return ans;
}
long long B(int x, int y, int r, int c) {
  int X = r * n;
  long long ans = 1LL * c / 2 * m * (x - X);
  if (c & 1) {
    ans += fuck(x - X, m, check(r, c - 1));
  }
  return ans;
}
long long C(int x, int y, int r, int c) {
  int Y = c * m;
  long long ans = 1LL * r / 2 * n * (y - Y);
  if (r & 1) {
    ans += fuck(n, y - Y, check(r - 1, c));
  }
  return ans;
}
long long D(int x, int y, int r, int c) {
  int X = r * n, Y = c * m;
  return fuck(x - X, y - Y, check(r, c));
}
long long query(int x, int y) {
  if (x == 0 || y == 0) {
    return 0;
  }
  int r = (x - 1) / n, c = (y - 1) / m;
  if (r == 0 && c == 0) {
    return D(x, y, r, c);
  }
  if (r == 0) {
    return D(x, y, r, c) + B(x, y, r, c);
  }
  if (c == 0) {
    return D(x, y, r, c) + C(x, y, r, c);
  }
  return A(x, y, r, c) + B(x, y, r, c) + C(x, y, r, c) + D(x, y, r, c);
}
long long solve(int x1, int x2, int y1, int y2) {
  return query(x2, y2) - query(x1 - 1, y2) - query(x2, y1 - 1) +
         query(x1 - 1, y1 - 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= m; j++) {
      char a;
      int x;
      cin >> a;
      x = a - '0';
      sum[i][j] = x - sum[i - 1][j - 1] + sum[i][j - 1] + sum[i - 1][j];
    }
  }
  while (q--) {
    int x1, x2, y1, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    printf("%lld\n", solve(x1, x2, y1, y2));
  }
  return 0;
}
