#include <bits/stdc++.h>
using namespace std;
long long n, m, c[1007][1007], q, p[1007][1007], p1[1007][1007];
bool isn(int x) {
  int k = 0;
  while (x > 1) {
    k++;
    x -= (1 << ((int)trunc(log2(x - 1))));
  }
  return k % 2;
}
long long query(int r, int c) {
  long long kr = r / n;
  long long _or = r % n;
  long long kc = c / m;
  long long oc = c % m;
  long long res;
  if (kr % 2 == 1 && kc % 2 == 1) {
    res = (kr * kc - 1) * n * m / 2;
    if (isn(kr) ^ isn(kc))
      res += p1[n][m];
    else
      res += p[n][m];
  } else
    res = kr * kc * n * m / 2;
  if (isn(kc + 1)) {
    if (kr % 2) {
      res += oc * n * (kr - 1) / 2;
      if (isn(kr))
        res += p[n][oc];
      else
        res += p1[n][oc];
    } else
      res += oc * n * kr / 2;
  } else {
    if (kr % 2) {
      res += oc * n * (kr - 1) / 2;
      if (isn(kr))
        res += p1[n][oc];
      else
        res += p[n][oc];
    } else
      res += oc * n * kr / 2;
  }
  if (isn(kr + 1)) {
    if (kc % 2) {
      res += _or * m * (kc - 1) / 2;
      if (isn(kc))
        res += p[_or][m];
      else
        res += p1[_or][m];
    } else
      res += _or * m * kc / 2;
  } else {
    if (kc % 2) {
      res += _or * m * (kc - 1) / 2;
      if (isn(kc))
        res += p1[_or][m];
      else
        res += p[_or][m];
    } else
      res += _or * m * kc / 2;
  }
  if (isn(kr + 1) ^ isn(kc + 1))
    res += p1[_or][oc];
  else
    res += p[_or][oc];
  return res;
}
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      char cr;
      cin >> cr;
      c[i][j] = (cr == '1');
      p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + c[i][j];
      p1[i][j] = p1[i - 1][j] + p1[i][j - 1] - p1[i - 1][j - 1] + 1 - c[i][j];
    }
  for (int i = 1; i <= q; ++i) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << query(x2, y2) - query(x1 - 1, y2) - query(x2, y1 - 1) +
                query(x1 - 1, y1 - 1)
         << endl;
  }
  return 0;
}
