#include <bits/stdc++.h>
using namespace std;
int cs;
long long int dp[32][2][2];
int vis[32][2][2];
bool Check(int n, int b) { return (n >> b) & 1; }
long long int solve(int pos, bool isSmall, bool parity, int n) {
  if (pos < 0) return (parity == 1);
  if (vis[pos][isSmall][parity] == cs) return dp[pos][isSmall][parity];
  vis[pos][isSmall][parity] = cs;
  long long int ret = 0;
  if (Check(n, pos))
    ret += solve(pos - 1, true, parity, n);
  else
    ret += solve(pos - 1, isSmall, parity, n);
  if (isSmall)
    ret += solve(pos - 1, true, parity ^ 1, n);
  else if (Check(n, pos))
    ret += solve(pos - 1, false, parity ^ 1, n);
  return dp[pos][isSmall][parity] = ret;
}
long long int Odd(int x) {
  cs++;
  return solve(31, false, 0, x);
}
int c[1005][1005];
bool Type(int x) { return __builtin_popcount(x) & 1; }
long long int Sum(int x, int y) { return c[x + 1][y + 1]; }
long long int ASum(int x, int y) { return Sum(x, y); }
long long int BSum(int x, int y) {
  long long int Total = (x + 1) * 1LL * (y + 1);
  return Total - ASum(x, y);
}
int n, m;
long long int F(int x, int y) {
  if (x < 0 || y < 0) return 0;
  int r = x / n;
  int c = y / m;
  int X = x % n;
  int Y = y % m;
  long long int Sum1 = 0;
  if (r && c) {
    long long int oddRow = Odd(r - 1);
    long long int oddCol = Odd(c - 1);
    long long int evn = oddRow * oddCol + (r - oddRow) * (c - oddCol);
    long long int odd = (r - oddRow) * oddCol + oddRow * (c - oddCol);
    Sum1 = evn * ASum(n - 1, m - 1) + odd * BSum(n - 1, m - 1);
  }
  long long int Sum2 = 0;
  if (c) {
    long long int oddCol = Odd(c - 1);
    long long int odd = oddCol;
    long long int evn = c - oddCol;
    if (Type(r)) swap(odd, evn);
    Sum2 = evn * ASum(X, m - 1) + odd * BSum(X, m - 1);
  }
  long long int Sum3 = 0;
  if (r) {
    long long int oddRow = Odd(r - 1);
    long long int odd = oddRow;
    long long int evn = r - oddRow;
    if (Type(c)) swap(odd, evn);
    Sum3 = evn * ASum(n - 1, Y) + odd * BSum(n - 1, Y);
  }
  long long int Sum4 = 0;
  if (Type(r) ^ Type(c))
    Sum4 = BSum(X, Y);
  else
    Sum4 = ASum(X, Y);
  return Sum1 + Sum2 + Sum3 + Sum4;
}
int main() {
  int q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) {
      c[i][j] = c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1] + s[j - 1] - '0';
    }
  }
  for (int cs = 1; cs <= q; cs++) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1--;
    y1--;
    x2--;
    y2--;
    long long int Ans = 0;
    Ans += F(x2, y2) - F(x1 - 1, y2) - F(x2, y1 - 1) + F(x1 - 1, y1 - 1);
    printf("%lld\n", Ans);
  }
}
