#include <bits/stdc++.h>
using namespace std;
int dp[2100][2100];
vector<string> s;
int n, m;
void precalc() {
  for (int i = 0; i < n; i++) {
    int cur = 0;
    for (int j = 0; j < m; j++) {
      cur += s[i][j] == '1';
      dp[i + 1][j + 1] = dp[i][j + 1] + cur;
    }
  }
}
int jump(int from, int len) {
  int res = 0;
  for (int i = 0; i < 30; i++) res += (len >> i) % 2;
  return from ^ (res % 2);
}
long long subs(long long x, long long y, int inv, long long cnt) {
  long long result;
  if (inv)
    result = (cnt - cnt / 2) * (x * y - dp[x][y]) + cnt / 2 * dp[x][y];
  else
    result = cnt / 2 * (x * y - dp[x][y]) + (cnt - cnt / 2) * dp[x][y];
  return result;
}
long long solve(long long x, long long y) {
  long long result = n * m / 2 * (x / n) * (y / m) +
                     subs(n, y % m, jump(jump(0, y / m), x / n - 1), x / n) +
                     subs(x % n, m, jump(jump(0, x / n), y / m - 1), y / m) +
                     subs(x % n, y % m, jump(jump(0, y / m), x / n), 1);
  return result;
}
int main() {
  int q;
  cin >> n >> m >> q;
  s.resize(n * 2);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    s[i + n] = s[i];
    for (int j = 0; j < m; j++) s[i + n][j] = s[i + n][j] == '0' ? '1' : '0';
    string tmp = s[i + n];
    s[i + n] += s[i];
    s[i] += tmp;
  }
  n *= 2;
  m *= 2;
  precalc();
  for (int i = 0; i < q; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--;
    cout << solve(x2, y2) + solve(x1, y1) - solve(x1, y2) - solve(x2, y1)
         << endl;
  }
  return 0;
}
