#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
template <typename T>
void read(T &x) {
  x = 0;
  int s = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') s = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  x *= s;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
const int maxn = 1e3 + 5;
int n, m, q, dp[maxn][maxn];
int X1, Y1, X2, Y2;
char ch[maxn][maxn];
int Invert(int a, int b) {
  return (__builtin_popcount(a - 1) + __builtin_popcount(b - 1)) & 1;
}
long long f(int x, int y) {
  if (!x || !y) return 0;
  int a = (x - 1) / n + 1, b = (y - 1) / m + 1;
  long long res = 0;
  int nn = x - (a - 1) * n, mm = y - (b - 1) * m;
  res += Invert(a, b) ? nn * mm - dp[nn][mm] : dp[nn][mm];
  if (a % 2 == 1 && b % 2 == 1) {
    res += ((long long)x * y - (long long)nn * mm) / 2;
  } else if (a % 2 == 0 && b % 2 != 0) {
    res += (long long)x * (b - 1) / 2 * m;
    res += (long long)(a - 2) / 2 * n * mm;
    res += Invert(a - 1, b) ? n * mm - dp[n][mm] : dp[n][mm];
  } else if (a % 2 != 0 && b % 2 == 0) {
    res += (long long)y * (a - 1) / 2 * n;
    res += (long long)(b - 2) / 2 * m * nn;
    res += Invert(a, b - 1) ? m * nn - dp[nn][m] : dp[nn][m];
  } else {
    res += f(x - nn, y - mm);
    res += (long long)(b - 2) / 2 * m * nn;
    res += (long long)(a - 2) / 2 * n * mm;
    res += Invert(a - 1, b) ? n * mm - dp[n][mm] : dp[n][mm];
    res += Invert(a, b - 1) ? nn * m - dp[nn][m] : dp[nn][m];
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) cin >> (ch[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      dp[i][j] =
          dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + ch[i][j] - '0';
    }
  while (q--) {
    cin >> X1 >> Y1 >> X2 >> Y2;
    cout << f(X2, Y2) - f(X2, Y1 - 1) - f(X1 - 1, Y2) + f(X1 - 1, Y1 - 1)
         << endl;
  }
  return 0;
}
