#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 2000 + 20;
int n, m, q, a[N][N], part[N][N];
string s[N];
inline int get(int x) { return (__builtin_popcount(x) & 1 ? -1 : +1); }
inline ll f(int x, int y) {
  ll res = (1ll * x * y - (x % n) * (y % m)) / 2;
  if (get((x / n) ^ (y / m)) == 1)
    res += part[x % n][y % m];
  else
    res += (x % n) * (y % m) - part[x % n][y % m];
  return res;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) {
      a[i][j] = a[i + n][j + m] = s[i][j] - '0';
      a[i + n][j] = a[i][j + m] = a[i][j] ^ 1;
    }
  }
  n <<= 1, m <<= 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      part[i + 1][j + 1] =
          a[i][j] + part[i][j + 1] + part[i + 1][j] - part[i][j];
  while (q--) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--;
    cout << f(x2, y2) - f(x1, y2) - f(x2, y1) + f(x1, y1) << '\n';
  }
}
