#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e3 + 15;
const int MOD = (int)1e9 + 7;
const double eps = 1e-6;
int G[N][N];
inline int calcK(int x, int y, int n, int m) {
  x = (x - 1) / (2 * n) + 1;
  y = (y - 1) / (2 * m) + 1;
  int k = 0;
  for (int j = 30; j >= 0; j--) {
    if ((1 << j) < x) {
      x -= (1 << j);
      k ^= 1;
    }
  }
  for (int j = 30; j >= 0; j--) {
    if ((1 << j) < y) {
      y -= (1 << j);
      k ^= 1;
    }
  }
  return k;
}
inline long long calc(int x1, int y1, int x2, int y2, int n, int m) {
  int k = calcK(x2, y2, n, m);
  x1 = (x1 - 1) % (2 * n) + 1;
  x2 = (x2 - 1) % (2 * n) + 1;
  y1 = (y1 - 1) % (2 * m) + 1;
  y2 = (y2 - 1) % (2 * m) + 1;
  long long ans = G[x2][y2] - G[x2][y1 - 1] - G[x1 - 1][y2] + G[x1 - 1][y1 - 1];
  return !k ? ans : (long long)(x2 - x1 + 1) * (y2 - y1 + 1) - ans;
}
inline long long solve(int x, int y, int n, int m) {
  if (x == 0 || y == 0) {
    return 0;
  }
  long long xp = (x + 2 * n - 1) / (2 * n) * (2 * n);
  long long yp = (y + 2 * m - 1) / (2 * m) * (2 * m);
  long long ans = xp * yp / 2;
  ans -= (xp - x) * yp / 2;
  ans -= (yp - y) * xp / 2;
  if (x + 1 <= xp && y + 1 <= yp) {
    ans += calc(x + 1, y + 1, xp, yp, n, m);
  }
  return ans;
}
int main() {
  int n, m, q;
  while (~scanf("%d%d%d", &n, &m, &q)) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%1d", &G[i][j]);
        G[i + n][j] = G[i][j + m] = !G[i][j];
        G[i + n][j + m] = G[i][j];
      }
    }
    for (int i = 1; i <= 2 * n; i++) {
      for (int j = 1; j <= 2 * m; j++) {
        G[i][j] = G[i][j] + G[i - 1][j] + G[i][j - 1] - G[i - 1][j - 1];
      }
    }
    while (q--) {
      int x1, y1, x2, y2;
      scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
      printf("%lld\n", solve(x2, y2, n, m) - solve(x2, y1 - 1, n, m) -
                           solve(x1 - 1, y2, n, m) +
                           solve(x1 - 1, y1 - 1, n, m));
    }
  }
}
