#include <bits/stdc++.h>
using namespace std;
const int N = 2019;
int n, m, Q, s[N][N];
char str[N];
long long calc(long long x, long long y) {
  long long ret = (x * y - (x % n) * (y % m)) / 2;
  long long t = (x / n) ^ (y / m), num = 0;
  while (t) num += t & 1, t >>= 1;
  if (num & 1)
    ret += (x % n) * (y % m) - s[x % n][y % m];
  else
    ret += s[x % n][y % m];
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str + 1);
    for (int j = 1; j <= m; j++)
      s[i][j] = s[i + n][j + m] = str[j] - '0',
      s[i + n][j] = s[i][j + m] = s[i][j] ^ 1;
  }
  n <<= 1, m <<= 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
  while (Q--) {
    long long a, b, c, d;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%lld\n",
           calc(c, d) + calc(a - 1, b - 1) - calc(a - 1, d) - calc(c, b - 1));
  }
}
