#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n, m, s[maxn][maxn], q;
int bitcnt(int x) {
  int ans = 0;
  while (x) {
    if (x & 1) ++ans;
    x >>= 1;
  }
  return ans;
}
bool overturn(int x, int y) { return (bitcnt(x - 1) + bitcnt(y - 1)) & 1; }
long long sum(int x, int y) {
  if (!x or !y) return 0;
  long long ans = 0, fx = (x + n - 1) / n, fy = (y + m - 1) / m,
            rx = x - (fx - 1) * n, ry = y - (fy - 1) * m;
  ans += (fx - 1) * (fy - 1) / 2 * n * m;
  if ((fx - 1) & 1 and (fy - 1) & 1) {
    if (overturn(fx - 1, fy - 1))
      ans += n * m - s[n][m];
    else
      ans += s[n][m];
  }
  ans += (fx - 1) / 2 * n * ry;
  if ((fx - 1) & 1) {
    if (overturn(fx - 1, fy))
      ans += n * ry - s[n][ry];
    else
      ans += s[n][ry];
  }
  ans += (fy - 1) / 2 * rx * m;
  if ((fy - 1) & 1) {
    if (overturn(fx, fy - 1))
      ans += rx * m - s[rx][m];
    else
      ans += s[rx][m];
  }
  if (overturn(fx, fy))
    ans += rx * ry - s[rx][ry];
  else
    ans += s[rx][ry];
  return ans;
}
char ch;
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      scanf(" %c", &ch);
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + ch - '0';
    }
  for (int i = 1, x1, y1, x2, y2; i <= q; ++i) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << sum(x2, y2) - sum(x1 - 1, y2) - sum(x2, y1 - 1) +
                sum(x1 - 1, y1 - 1)
         << endl;
  }
  return 0;
}
