#include <bits/stdc++.h>
using namespace std;
int a[1009][1009], b[1009][1009], n, m;
int find(int x, int target) {
  int y = x;
  while (2 * y < target) {
    y *= 2;
  }
  return y;
}
long long int solve(int x2, int y2) {
  if (x2 <= n && y2 <= m) {
    return b[x2][y2];
  } else if (x2 > n) {
    int x = find(n, x2);
    if (2 * x == x2) {
      return 1ll * y2 * (x2 - x);
    }
    return solve(x, y2) + 1ll * y2 * (x2 - x) - solve(x2 - x, y2);
  } else if (y2 > m) {
    int y = find(m, y2);
    if (2 * y == y2) {
      return 1ll * x2 * (y2 - y);
    }
    return solve(x2, y) + 1ll * x2 * (y2 - y) - solve(x2, y2 - y);
  }
}
int main() {
  int i, j, k, x, y, t;
  scanf("%d%d%d", &n, &m, &t);
  char c;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> c;
      if (c == '1') {
        a[i][j] = 1;
      }
      a[i][j] += a[i][j - 1];
      b[i][j] = b[i - 1][j] + a[i][j];
    }
  }
  long long int ans, x1, x2, y1, y2;
  while (t--) {
    scanf("%d%d", &x1, &y1);
    scanf("%d%d", &x2, &y2);
    ans = solve(x2, y2) + solve(x1 - 1, y1 - 1) - solve(x2, y1 - 1) -
          solve(x1 - 1, y2);
    printf("%lld\n", ans);
    ;
  }
}
