#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
int n, m, q;
char a[2 * 1003][2 * 1003];
long long sum[2 * 1003][2 * 1003], sum1[2 * 1003][2 * 1003], ret, cn_n, cm_n;
long long mx, my;
long long sx1, sy1, sx2, sy2;
void dcy(long long left, long long right, long long lx, long long rx) {
  if (left > sy2 || right < sy1) return;
  if (left >= sy1 && right <= sy2) {
    ret += (right - left + 1) * (rx - lx + 1) / 2;
  } else if (right - left + 1 == m) {
    long long ly = max(sy1, left), ry = min(sy2, right);
    long long x = (lx - 1) / n, y = (ly - 1) / m;
    int k = ((x) ^ (y));
    int k1 = 0;
    while (k) k1 += k & 1, k >>= 1;
    lx = (lx - 1) % n + 1, ly = (ly - 1) % m + 1, rx = (rx - 1) % n + 1,
    ry = (ry - 1) % m + 1;
    if (k1 & 1)
      ret += sum1[rx][ry] + sum1[lx - 1][ly - 1] - sum1[lx - 1][ry] -
             sum1[rx][ly - 1];
    else
      ret +=
          sum[rx][ry] + sum[lx - 1][ly - 1] - sum[lx - 1][ry] - sum[rx][ly - 1];
  } else {
    long long mid = (left + right) >> 1;
    dcy(left, mid, lx, rx), dcy(mid + 1, right, lx, rx);
  }
}
void dcx(long long left, long long right) {
  if (left > sx2 || right < sx1) return;
  if (left >= sx1 && right <= sx2)
    ret += (sy2 - sy1 + 1) * (right - left + 1) / 2;
  else if (right - left + 1 == n)
    dcy(1, my, max(left, sx1), min(right, sx2));
  else {
    int mid = (left + right) >> 1;
    dcx(left, mid), dcx(mid + 1, right);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int i, j;
  scanf("%d%d%d", &n, &m, &q);
  for (i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      sum[i][j] = sum[i + n][j + m] = a[i][j] - '0';
      sum[i + n][j] = sum[i][j + m] = sum[i][j] ^ 1;
    }
  n <<= 1, m <<= 1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
      sum1[i][j] = i * j - sum[i][j];
    }
  }
  mx = n;
  while (mx < 1e9) {
    mx *= 2;
  }
  my = m;
  while (my < 1e9) {
    my *= 2;
  }
  while (q--) {
    scanf("%d%d%d%d", &sx1, &sy1, &sx2, &sy2);
    ret = 0;
    dcx(1, mx);
    cout << ret << endl;
  }
  return 0;
}
