#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
int N, M;
int dp[2010][2010];
long long T(long long n, long long m) {
  if (n >= 2 * N) {
    long long base = m * N;
    long long k = 2 * N;
    while (n - 2 * k > 0) {
      k *= 2;
      base *= 2;
    }
    return base + (n - k) * m - T(n - k, m);
  }
  if (m >= 2 * M) {
    long long base = n * M;
    long long k = 2 * M;
    while (m - 2 * k > 0) {
      k *= 2;
      base *= 2;
    }
    return base + n * (m - k) - T(n, m - k);
  }
  return dp[n][m];
}
int main() {
  int q;
  cin >> N >> M >> q;
  vector<string> s;
  for (int i = 0; i < N; ++i) {
    string t;
    cin >> t;
    s.push_back(t);
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      dp[i + 1][j + 1] = s[i][j] - '0';
      dp[i + 1 + N][j + 1 + M] = dp[i + 1][j + 1];
    }
  }
  for (int i = N + 1; i <= 2 * N; ++i) {
    for (int j = 1; j <= M; ++j) {
      dp[i][j] = dp[i - N][j] ^ 1;
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = M + 1; j <= 2 * M; ++j) {
      dp[i][j] = dp[i][j - M] ^ 1;
    }
  }
  for (int i = 1; i <= 2 * N; ++i)
    for (int j = 1; j <= 2 * M; ++j)
      dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
  while (q--) {
    int x, y, l, k;
    scanf("%d%d%d%d", &x, &y, &l, &k);
    long long ans = T(l, k) - T(x - 1, k) - T(l, y - 1) + T(x - 1, y - 1);
    printf("%I64lld\n", ans);
  }
  return 0;
}
