#include <bits/stdc++.h>
using namespace std;
void build_csum(vector<vector<int>> &csum, int n, int m, vector<string> field);
long long query(vector<vector<int>> &csum, int n, int m, int x1, int y1, int x2,
                int y2);
long long query(vector<vector<int>> &csum, int n, int m, long long x,
                long long y);
int countones(int x);
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<string> field(n);
  for (int i = 0; i < n; i++) {
    cin >> field[i];
  }
  vector<vector<int>> csum(2 * n + 1);
  build_csum(csum, n, m, field);
  for (int i = 0; i < q; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << query(csum, n, m, y1, x1, y2, x2) << '\n';
  }
}
void build_csum(vector<vector<int>> &csum, int n, int m, vector<string> field) {
  for (int i = 0; i < m * 2 + 1; i++) {
    csum[0].push_back(0);
  }
  for (int r = 0; r < n * 2; r++) {
    csum[r + 1].push_back(0);
    for (int c = 0; c < m * 2; c++) {
      int v = csum[r + 1][c] + csum[r][c + 1] - csum[r][c];
      if ((c < m) ^ (r < n)) {
        csum[r + 1].push_back(v + 1 - (field[r % n][c % m] - '0'));
      } else {
        csum[r + 1].push_back(v + (field[r % n][c % m] - '0'));
      }
    }
  }
}
long long query(vector<vector<int>> &csum, int n, int m, int x1, int y1, int x2,
                int y2) {
  return query(csum, n, m, x2, y2) - query(csum, n, m, x1 - 1, y2) -
         query(csum, n, m, x2, y1 - 1) + query(csum, n, m, x1 - 1, y1 - 1);
}
long long query(vector<vector<int>> &csum, int n, int m, long long x,
                long long y) {
  if (x == 0 || y == 0) return 0;
  if ((countones(y / (2 * n)) + countones(x / (2 * m))) % 2 == 1)
    return (y % (2 * n)) * (x % (2 * m)) - csum[y % (2 * n)][x % (2 * m)] +
           (y / (2 * n)) * (x / (2 * m)) * csum[(2 * n)][(2 * m)] +
           (y / (2 * n)) * csum[(2 * n)][x % (2 * m)] +
           (x / (2 * m)) * csum[y % (2 * n)][(2 * m)];
  return csum[y % (2 * n)][x % (2 * m)] +
         (y / (2 * n)) * (x / (2 * m)) * csum[(2 * n)][(2 * m)] +
         (y / (2 * n)) * csum[(2 * n)][x % (2 * m)] +
         (x / (2 * m)) * csum[y % (2 * n)][(2 * m)];
}
int countones(int x) {
  int num = 0;
  while (x != 0) {
    if (x % 2 == 1) num++;
    x >>= 1;
  }
  return num;
}
