#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int c[1000][1000];
long long cc[1000][1000];
long long h[35], w[35];
int maxh, maxw;
long long calc3(long long x, long long y, int hi, int wi) {
  if (hi == 0 && wi == 0) return cc[x - 1][y - 1];
  if (hi == 0) return x * w[wi - 1];
  if (wi == 0) return y * h[hi - 1];
  return w[wi - 1] * h[hi];
}
long long calc2(long long x, long long y, int hi, int wi) {
  if (y == 0) return 0;
  if (wi == 0) return calc3(x, y, hi, 0);
  if (y <= w[wi - 1]) return calc2(x, y, hi, wi - 1);
  return calc3(x, w[wi - 1], hi, wi - 1) + (y - w[wi - 1]) * x -
         calc2(x, y - w[wi - 1], hi, wi - 1);
}
long long calc1(long long x, long long y, int hi) {
  if (x == 0) return 0;
  if (hi == 0) return calc2(x, y, 0, maxw);
  if (x <= h[hi - 1]) return calc1(x, y, hi - 1);
  return calc2(h[hi - 1], y, hi - 1, maxw) + (x - h[hi - 1]) * y -
         calc1(x - h[hi - 1], y, hi - 1);
}
long long sum(long long x1, long long y1, long long x2, long long y2) {
  long long res = calc1(x2 + 1, y2 + 1, maxh);
  if (x1 > 0) res -= calc1(x1, y2 + 1, maxh);
  if (y1 > 0) res -= calc1(x2 + 1, y1, maxh);
  if (x1 > 0 && y1 > 0) res += calc1(x1, y1, maxh);
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      char ch;
      cin >> ch;
      c[i][j] = ch - '0';
    }
  h[0] = n;
  while (h[maxh] <= 1e9) {
    maxh++;
    h[maxh] = h[maxh - 1] * 2;
  }
  w[0] = m;
  while (w[maxw] <= 1e9) {
    maxw++;
    w[maxw] = w[maxw - 1] * 2;
  }
  cc[0][0] = c[0][0];
  for (int i = 1; i < n; ++i) cc[i][0] = cc[i - 1][0] + c[i][0];
  for (int i = 1; i < m; ++i) cc[0][i] = cc[0][i - 1] + c[0][i];
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j)
      cc[i][j] = cc[i - 1][j] + cc[i][j - 1] - cc[i - 1][j - 1] + c[i][j];
  while (q--) {
    long long x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--;
    y1--;
    x2--;
    y2--;
    cout << sum(x1, y1, x2, y2) << "\n";
  }
}
