#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, q, a[N][N], b[N][N], x1, x2, _____y1, y2;
inline int pre(int x) {
  if (x < 0) return 0;
  if (x % 2 == 1) return (x >> 1) + 1;
  return (x >> 1) + (__builtin_popcount(x) & 1);
}
inline int calc1(int x1, int _____y1, int x2, int y2) {
  return b[x2][y2] - (x1 == 0 ? 0 : b[x1 - 1][y2]) -
         (_____y1 == 0 ? 0 : b[x2][_____y1 - 1]) +
         (x1 == 0 || _____y1 == 0 ? 0 : b[x1 - 1][_____y1 - 1]);
}
inline int calc0(int x1, int _____y1, int x2, int y2) {
  return (x2 - x1 + 1) * (y2 - _____y1 + 1) - calc1(x1, _____y1, x2, y2);
}
long long get(int x1, int _____y1, int x2, int y2) {
  if (x1 > x2 || _____y1 > y2) return 0;
  int v1 = pre(x2 / n) - pre(x1 / n - 1),
      v2 = pre(y2 / m) - pre(_____y1 / m - 1), v3 = x2 / n - x1 / n + 1 - v1,
      v4 = y2 / m - _____y1 / m + 1 - v2;
  x1 %= n;
  _____y1 %= m;
  x2 %= n;
  y2 %= m;
  return (long long)calc0(x1, _____y1, x2, y2) *
             ((long long)v1 * v4 + (long long)v2 * v3) +
         (long long)calc1(x1, _____y1, x2, y2) *
             ((long long)v1 * v2 + (long long)v3 * v4);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%1d", &a[i][j]), b[i][j] = a[i][j];
  for (int i = 1; i < n; i++)
    for (int j = 0; j < m; j++) b[i][j] += b[i - 1][j];
  for (int i = 0; i < n; i++)
    for (int j = 1; j < m; j++) b[i][j] += b[i][j - 1];
  while (q--) {
    scanf("%d%d%d%d", &x1, &_____y1, &x2, &y2);
    x1--;
    _____y1--;
    x2--;
    y2--;
    int l1 = x1 / n, r1 = x2 / n, l2 = _____y1 / m, r2 = y2 / m;
    long long ans = 0;
    if (l1 == r1 && l2 == r2) {
      ans = get(x1, _____y1, x2, y2);
    } else if (l1 == r1) {
      ans += get(x1, _____y1, x2, l2 * m + m - 1);
      ans += get(x1, l2 * m + m, x2, r2 * m - 1);
      ans += get(x1, r2 * m, x2, y2);
    } else if (l2 == r2) {
      ans += get(x1, _____y1, l1 * n + n - 1, y2);
      ans += get(l1 * n + n, _____y1, r1 * n - 1, y2);
      ans += get(r1 * n, _____y1, x2, y2);
    } else {
      ans += get(x1, _____y1, l1 * n + n - 1, l2 * m + m - 1);
      ans += get(l1 * n + n, _____y1, r1 * n - 1, l2 * m + m - 1);
      ans += get(r1 * n, _____y1, x2, l2 * m + m - 1);
      ans += get(x1, l2 * m + m, l1 * n + n - 1, r2 * m - 1);
      ans += get(l1 * n + n, l2 * m + m, r1 * n - 1, r2 * m - 1);
      ans += get(r1 * n, l2 * m + m, x2, r2 * m - 1);
      ans += get(x1, r2 * m, l1 * n + n - 1, y2);
      ans += get(l1 * n + n, r2 * m, r1 * n - 1, y2);
      ans += get(r1 * n, r2 * m, x2, y2);
    }
    printf("%lld\n", ans);
  }
}
