#include <bits/stdc++.h>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ') {
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
const int N = 1 << 10 | 5;
int n0, m0, q, s[N][N], lg[N * N << 1];
char bit[N][N];
long long query(int n, int m) {
  if (!n || !m) return 0;
  int i = n / n0 > (1 << 21) ? lg[(n / n0) >> 21] + 21 : lg[n / n0];
  int j = m / m0 > (1 << 21) ? lg[(m / m0) >> 21] + 21 : lg[m / m0];
  long long ret = 0;
  i = i >= 0 ? n0 * (1 << i) : n, j = j >= 0 ? m0 * (1 << j) : m;
  if (i <= n0 && j <= m0)
    ret = s[i][j];
  else
    ret = 1ll * i * j >> 1;
  return ret + 1ll * i * (m - j) - query(i, m - j) + 1ll * (n - i) * j -
         query(n - i, j) + query(n - i, m - j);
}
int main() {
  n0 = read(), m0 = read(), q = read(), lg[0] = -1;
  for (int i = 1; i <= 1 << 21; ++i) lg[i] = lg[i >> 1] + 1;
  for (int i = 1; i <= n0; ++i) scanf("%s", bit[i] + 1);
  for (int i = 1; i <= n0; ++i)
    for (int j = 1; j <= m0; ++j)
      s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1] + (bit[i][j] - '0');
  while (q--) {
    int x1 = read(), y1 = read(), x2 = read(), y2 = read();
    printf("%I64d\n", query(x2, y2) - query(x1 - 1, y2) - query(x2, y1 - 1) +
                          query(x1 - 1, y1 - 1));
  }
  return 0;
}
