#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int a[N][N];
int sum[N][N];
int m, n, q;
long long solve(long long x, long long y) {
  long long rx = x % (2 * n), ry = y % (2 * m);
  long long ans = (x * y - rx * ry) / 2;
  long long extra = sum[rx][ry];
  x /= 2 * n;
  y /= 2 * m;
  if (__builtin_popcountll(x ^ y) % 2) extra = rx * ry - extra;
  return ans + extra;
}
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      a[i][j] = a[i + n][j + m] = c - '0';
      a[i + n][j] = a[i][j + m] = !a[i][j];
    }
  for (int i = 1; i <= 2 * n; i++)
    for (int j = 1; j <= 2 * m; j++) {
      sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + a[i][j];
    }
  while (q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    long long ans = solve(x2, y2) - solve(x1 - 1, y2) - solve(x2, y1 - 1) +
                    solve(x1 - 1, y1 - 1);
    cout << ans << endl;
  }
}
