#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<vector<long long> > v, kol;
bool g(long long x, long long y) {
  int kolx = 0, koly = 0;
  while (x > 0) {
    kolx += x % 2;
    x /= 2;
  }
  while (y > 0) {
    koly += y % 2;
    y /= 2;
  }
  return bool((kolx + koly + 1) % 2);
}
long long f(long long x, long long y) {
  if (x == -1 || y == -1) {
    return 0;
  }
  long long ans = (x / (2 * n)) * (y / (2 * m)) * kol[2 * n - 1][2 * m - 1] +
                  (y / (2 * m)) * kol[x % (2 * n)][2 * m - 1] +
                  +(x / (2 * n)) * kol[2 * n - 1][y % (2 * m)];
  if (g(x / (2 * n), y / (2 * m))) {
    ans += kol[x % (2 * n)][y % (2 * m)];
  } else {
    ans +=
        ((x % (2 * n) + 1) * (y % (2 * m) + 1) - kol[x % (2 * n)][y % (2 * m)]);
  }
  return ans;
}
int main() {
  cin >> n >> m >> q;
  v.resize(2 * n, vector<long long>(2 * m));
  kol.resize(2 * n, vector<long long>(2 * m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == '1') {
        v[i][j] = 1;
      } else {
        v[i][j] = 0;
      }
      v[n + i][j] = (v[i][j] + 1) % 2;
      v[i][m + j] = (v[i][j] + 1) % 2;
      v[n + i][m + j] = (v[i][j]) % 2;
    }
  }
  kol[0][0] = v[0][0];
  for (int i = 1; i < 2 * n; i++) {
    kol[i][0] = kol[i - 1][0] + v[i][0];
  }
  for (int i = 1; i < 2 * m; i++) {
    kol[0][i] = kol[0][i - 1] + v[0][i];
  }
  for (int i = 1; i < 2 * n; i++) {
    for (int j = 1; j < 2 * m; j++) {
      kol[i][j] = kol[i - 1][j] + kol[i][j - 1] - kol[i - 1][j - 1] + v[i][j];
    }
  }
  for (int qq = 0; qq < q; qq++) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1 -= 2;
    y1 -= 2;
    x2--;
    y2--;
    long long ans = f(x2, y2) - f(x2, y1) - f(x1, y2) + f(x1, y1);
    cout << ans << endl;
  }
  return 0;
}
