#include <bits/stdc++.h>
using namespace std;
template <class T, class T1>
int chkmin(T &x, const T1 &y) {
  return x > y ? x = y, 1 : 0;
}
template <class T, class T1>
int chkmax(T &x, const T1 &y) {
  return x < y ? x = y, 1 : 0;
}
const int MAXN = (1 << 11);
int q;
int n, m;
int64_t a[MAXN][MAXN];
void read() {
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) a[i][j] = s[j] - '0';
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      a[n + i][m + j] = a[i][j];
      a[n + i][j] = a[i][j] ^ 1;
      a[i][m + j] = a[i][j] ^ 1;
    }
  n *= 2;
  m *= 2;
}
int pn(int i) { return (i / n) & 1; }
int pm(int i) { return (i / m) & 1; }
int get_par(int x, int y) {
  return (__builtin_popcount(x) % 2) ^ (__builtin_popcount(y) % 2);
}
int64_t sum(int x, int y) {
  if (x < 0 || y < 0) return 0;
  if (x < n && y < m) return a[x][y];
  int64_t ret = 0;
  int M = (y / m) * m;
  int N = (x / n) * n;
  int p = get_par(x / n, y / m);
  if (p)
    ret += (x - N + 1) * 1ll * (y - M + 1) - a[x - N][y - M];
  else
    ret += a[x - N][y - M];
  ret += N * 1ll * (y + 1) / 2ll;
  ret += M * 1ll * (x + 1) / 2ll;
  ret -= N * 1ll * M / 2ll;
  return ret;
}
void solve() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (i) a[i][j] += a[i - 1][j];
      if (j) a[i][j] += a[i][j - 1];
      if (i && j) a[i][j] -= a[i - 1][j - 1];
    }
  for (int i = 0; i < q; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    cout << sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) +
                sum(x1 - 1, y1 - 1)
         << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
