#include <bits/stdc++.h>
#pragma comment(linker, "/STACK: 1024000000,1024000000")
using namespace std;
const int N = 2019;
int a[N][N], sm[N][N];
int n, m, q;
char s[N][N];
long long qry(long long x, long long y) {
  long long xx = x / n, yy = y / m;
  int rx = x % n, ry = y % m;
  long long ans = (x * y - rx * ry) / 2;
  if ((__builtin_popcount(xx) + __builtin_popcount(yy)) & 1)
    ans += 1ll * rx * ry - sm[rx][ry];
  else
    ans += 1ll * sm[rx][ry];
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (int j = 1; j <= m; j++) {
      a[i][j] = a[i + n][j + m] = s[i][j] - '0';
      a[i + n][j] = a[i][j + m] = a[i][j] ^ 1;
    }
  }
  n <<= 1, m <<= 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      sm[i][j] += a[i][j] + sm[i - 1][j] + sm[i][j - 1] - sm[i - 1][j - 1];
  ;
  for (int i = 1; i <= q; i++) {
    int u, v, w, z;
    scanf("%d%d%d%d", &u, &v, &w, &z);
    u--, v--;
    printf("%lld\n", qry(w, z) - qry(w, v) - qry(u, z) + qry(u, v));
  }
  return 0;
}
