#include <bits/stdc++.h>
#pragma GCC target("sse4.2")
using namespace std;
bool home = 1;
signed realMain();
mt19937 rng_home(0);
mt19937 rng_oj((long long)(new char));
long long rng() {
  if (home) {
    return rng_home();
  } else {
    return rng_oj();
  }
}
unsigned long long rng_ull() {
  return (unsigned long long)rng() * rng() ^
         ((unsigned long long)rng() * rng());
}
long long rng_range(long long l, long long r) {
  return l + abs(rng()) % (r - l + 1);
}
signed main() {
  home = 0;
  if (home) {
    freopen("tony_stark", "r", stdin);
  } else {
    ios::sync_with_stdio(0);
    cin.tie(0);
  }
  realMain();
}
long long nr(long long n, long long coef) {
  if (n == 0) {
    return (coef == 0);
  }
  if (n == 1) {
    return 1;
  }
  long long lg = log2(n), m = (1 << lg);
  long long x = (1 << (lg - 1)) + nr(n - m, coef ^ 1);
  return x;
}
long long f(long long n, long long m) {
  long long x = nr(n, 0), y = nr(m, 0);
  return x * (m + 1 - y) + y * (n + 1 - x);
}
const long long N = 1000 + 7;
long long n, m, q, a[N][N], suma[N][N];
long long sum(long long r1, long long c1, long long r2, long long c2) {
  r1++;
  c1++;
  r2++;
  c2++;
  return suma[r2][c2] - suma[r1 - 1][c2] - suma[r2][c1 - 1] +
         suma[r1 - 1][c1 - 1];
}
long long get(long long r, long long c) {
  r--;
  c--;
  if (r < 0 || c < 0) return 0;
  long long ret = 0, li = r % n, lj = c % m, ff = r / n, ss = c / m;
  if (0 <= min(r, li) && 0 <= min(c, lj)) {
    long long val = sum(0, 0, min(r, li), min(c, lj));
    long long cx = ff;
    long long cy = ss;
    long long cnt = f(cx, cy);
    ret += cnt * ((min(r, li) + 1) * (min(c, lj) + 1) - val);
    ret += ((cx + 1) * (cy + 1) - cnt) * val;
  }
  if (li + 1 <= min(n - 1, r) && 0 <= min(lj, c)) {
    long long val = sum(li + 1, 0, min(n - 1, r), min(lj, c));
    long long cx = ff - 1;
    long long cy = ss;
    long long cnt = f(cx, cy);
    ret += cnt * ((min(n - 1, r) - li) * (min(lj, c) + 1) - val);
    ret += ((cx + 1) * (cy + 1) - cnt) * val;
  }
  if (0 <= min(r, li) && lj + 1 <= min(c, m - 1)) {
    long long val = sum(0, lj + 1, min(r, li), min(c, m - 1));
    long long cx = ff;
    long long cy = ss - 1;
    long long cnt = f(cx, cy);
    ret += cnt * ((min(r, li) + 1) * (min(c, m - 1) - lj) - val);
    ret += ((cx + 1) * (cy + 1) - cnt) * val;
  }
  if (li + 1 <= min(r, n - 1) && lj + 1 <= min(c, m - 1)) {
    long long val = sum(li + 1, lj + 1, min(r, n - 1), min(c, m - 1));
    long long cx = ff - 1;
    long long cy = ss - 1;
    long long cnt = f(cx, cy);
    ret += cnt * ((min(r, n - 1) - li) * (min(c, m - 1) - lj) - val);
    ret += ((cx + 1) * (cy + 1) - cnt) * val;
  }
  return ret;
}
signed realMain() {
  cin >> n >> m >> q;
  for (long long i = 1; i <= n; i++) {
    string str;
    cin >> str;
    long long cur = 0;
    for (long long j = 1; j <= m; j++) {
      a[i][j] = str[j - 1] - '0';
      cur += a[i][j];
      suma[i][j] = suma[i - 1][j] + cur;
    }
  }
  while (q--) {
    long long r1, c1, r2, c2, ret;
    cin >> r1 >> c1 >> r2 >> c2;
    ret = get(r2, c2) - get(r1 - 1, c2) - get(r2, c1 - 1) + get(r1 - 1, c1 - 1);
    cout << ret << "\n";
  }
  return 0;
}
