#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
int a[1005][1005];
long long pfs[1005][1005];
string s;
long long Ones(int x1, int x2, int y1, int y2) {
  if (x1 > x2 || y1 > y2) return 0;
  return pfs[x2][y2] - (y1 ? pfs[x2][y1 - 1] : 0) - (x1 ? pfs[x1 - 1][y2] : 0) +
         (x1 && y1 ? pfs[x1 - 1][y1 - 1] : 0);
}
long long Zeros(int x1, int x2, int y1, int y2) {
  if (x1 > x2 || y1 > y2) return 0;
  return (x2 - x1 + 1) * (y2 - y1 + 1) - Ones(x1, x2, y1, y2);
}
long long get(long long x, long long y1, long long y2) {
  long long k = 0, t = x;
  while (t) k += t & 1LL, t >>= 1LL;
  if (x % 2 == 0) {
    if (y1 == -1)
      return (x / 2LL) * (y2 - y1 + 1) + (k % 2 == 0);
    else {
      long long O = get(y2, -1, -1) - (y1 ? get(y1 - 1, -1, -1) : 0);
      return (x / 2LL) * (y2 - y1 + 1) + (k % 2 == 0 ? O : y2 - y1 + 1 - O);
    }
  } else
    return ((x + 1) / 2LL) * (y2 - y1 + 1);
}
long long OnesM(long long x1, long long x2, long long y1, long long y2) {
  if (x1 > x2 || y1 > y2) return 0;
  return get(x2, y1, y2) - (x1 ? get(x1 - 1, y1, y2) : 0);
}
long long ZerosM(long long x1, long long x2, long long y1, long long y2) {
  if (x1 > x2 || y1 > y2) return 0;
  return 1LL * (x2 - x1 + 1) * (y2 - y1 + 1) - OnesM(x1, x2, y1, y2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    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++)
      pfs[i][j] = a[i][j] + (i ? pfs[i - 1][j] : 0) + (j ? pfs[i][j - 1] : 0) -
                  (i && j ? pfs[i - 1][j - 1] : 0);
  while (q--) {
    long long x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    long long x1m = x1 / n, x2m = x2 / n;
    long long y1m = y1 / m, y2m = y2 / m;
    x1 %= n;
    x2 %= n;
    y1 %= m;
    y2 %= m;
    long long ans = 0;
    if (x1m == x2m && y1m == y2m) {
      if (OnesM(x1m, x2m, y1m, y2m))
        ans = Ones(x1, x2, y1, y2);
      else
        ans = Zeros(x1, x2, y1, y2);
    } else if (x1m == x2m) {
      if (OnesM(x1m, x2m, y1m, y1m))
        ans = Ones(x1, x2, y1, m - 1);
      else
        ans = Zeros(x1, x2, y1, m - 1);
      if (OnesM(x1m, x2m, y2m, y2m))
        ans += Ones(x1, x2, 0, y2);
      else
        ans += Zeros(x1, x2, 0, y2);
      ans += OnesM(x1m, x2m, y1m + 1, y2m - 1) * Ones(x1, x2, 0, m - 1);
      ans += ZerosM(x1m, x2m, y1m + 1, y2m - 1) * Zeros(x1, x2, 0, m - 1);
    } else if (y1m == y2m) {
      if (OnesM(x1m, x1m, y1m, y2m))
        ans = Ones(x1, n - 1, y1, y2);
      else
        ans = Zeros(x1, n - 1, y1, y2);
      if (OnesM(x2m, x2m, y1m, y2m))
        ans += Ones(0, x2, y1, y2);
      else
        ans += Zeros(0, x2, y1, y2);
      ans += OnesM(x1m + 1, x2m - 1, y1m, y2m) * Ones(0, n - 1, y1, y2);
      ans += ZerosM(x1m + 1, x2m - 1, y1m, y2m) * Zeros(0, n - 1, y1, y2);
    } else {
      if (OnesM(x1m, x1m, y1m, y1m))
        ans = Ones(x1, n - 1, y1, m - 1);
      else
        ans = Zeros(x1, n - 1, y1, m - 1);
      if (OnesM(x2m, x2m, y1m, y1m))
        ans += Ones(0, x2, y1, m - 1);
      else
        ans += Zeros(0, x2, y1, m - 1);
      if (OnesM(x1m, x1m, y2m, y2m))
        ans += Ones(x1, n - 1, 0, y2);
      else
        ans += Zeros(x1, n - 1, 0, y2);
      if (OnesM(x2m, x2m, y2m, y2m))
        ans += Ones(0, x2, 0, y2);
      else
        ans += Zeros(0, x2, 0, y2);
      ans += OnesM(x1m + 1, x2m - 1, y1m, y1m) * Ones(0, n - 1, y1, m - 1);
      ans += ZerosM(x1m + 1, x2m - 1, y1m, y1m) * Zeros(0, n - 1, y1, m - 1);
      ans += OnesM(x1m, x1m, y1m + 1, y2m - 1) * Ones(x1, n - 1, 0, m - 1);
      ans += ZerosM(x1m, x1m, y1m + 1, y2m - 1) * Zeros(x1, n - 1, 0, m - 1);
      ans += OnesM(x1m + 1, x2m - 1, y2m, y2m) * Ones(0, n - 1, 0, y2);
      ans += ZerosM(x1m + 1, x2m - 1, y2m, y2m) * Zeros(0, n - 1, 0, y2);
      ans += OnesM(x2m, x2m, y1m + 1, y2m - 1) * Ones(0, x2, 0, m - 1);
      ans += ZerosM(x2m, x2m, y1m + 1, y2m - 1) * Zeros(0, x2, 0, m - 1);
      ans +=
          OnesM(x1m + 1, x2m - 1, y1m + 1, y2m - 1) * Ones(0, n - 1, 0, m - 1);
      ans += ZerosM(x1m + 1, x2m - 1, y1m + 1, y2m - 1) *
             Zeros(0, n - 1, 0, m - 1);
    }
    cout << ans << '\n';
  }
  return 0;
}
