#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
  fast_ios() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} fast_ios_;
template <typename T>
void ndarray(vector<T> &vec, int len) {
  vec.resize(len);
}
template <typename T, typename... Args>
void ndarray(vector<T> &vec, int len, Args... args) {
  vec.resize(len);
  for (auto &v : vec) ndarray(v, args...);
}
template <typename T>
bool mmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool mmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
  return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
  return make_pair(l.first - r.first, l.second - r.second);
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto v : vec) os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec) {
  os << "deq[";
  for (auto v : vec) os << v << ",";
  os << "]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
  os << "(" << pa.first << "," << pa.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp) {
  os << "{";
  for (auto v : mp) os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) {
  os << "{";
  for (auto v : mp) os << v.first << "=>" << v.second << ",";
  os << "}";
  return os;
}
int N, M, Q;
vector<string> C;
vector<vector<int>> ac;
void build() {
  for (int i = (0), i_end_ = (N); i < i_end_; i++) {
    string S = C[i];
    for (int j = (0), j_end_ = (S.size()); j < j_end_; j++)
      S[j] = (char)('1' - S[j] + '0');
    C[i] += S;
  }
  for (int i = (0), i_end_ = (N); i < i_end_; i++) {
    string S = C[i];
    for (int j = (0), j_end_ = (S.size()); j < j_end_; j++)
      S[j] = (char)('1' - S[j] + '0');
    C.push_back(S);
  }
  ac.assign(2 * N + 1, vector<int>(2 * M + 1));
  for (int i = (0), i_end_ = (2 * N); i < i_end_; i++)
    for (int j = (0), j_end_ = (2 * M); j < j_end_; j++)
      ac[i + 1][j + 1] =
          ac[i][j + 1] + ac[i + 1][j] - ac[i][j] + (C[i][j] == '1');
}
lint solve(lint X, lint Y) {
  if (!X or !Y) return 0;
  lint x = X % (2 * N), y = Y % (2 * M);
  int b = __builtin_popcountll(X / (2 * N)) + __builtin_popcountll(Y / (2 * M));
  lint me = (X * Y - x * y) / 2;
  lint ad = (b % 2 ? x * y - ac[x][y] : ac[x][y]);
  return me + ad;
}
int main() {
  cin >> N >> M >> Q;
  C.resize(N);
  for (int i = (0), i_end_ = (N); i < i_end_; i++) cin >> C[i];
  build();
  for (int _ = (0), __end_ = (Q); _ < __end_; _++) {
    int x, y, X, Y;
    cin >> x >> y >> X >> Y;
    lint ret =
        solve(X, Y) - solve(x - 1, Y) - solve(X, y - 1) + solve(x - 1, y - 1);
    printf("%lld\n", ret);
  }
}
