#include <bits/stdc++.h>
using namespace std;
char c[2005][2005];
int sum[2005][2005];
int n, m;
int cal(int xx, int yy) {
  return (__builtin_popcount(xx) + __builtin_popcount(yy)) & 1;
}
long long dc(long long first, long long second) {
  if (first == 0 || second == 0) return 0;
  long long xx = first / n, yy = second / m;
  long long res = 0;
  res = (first * second - (first - xx * n) * (second - yy * m)) / 2;
  if (cal(xx, yy))
    res += (first - xx * n) * (second - yy * m) -
           sum[first - xx * n][second - yy * m];
  else
    res += sum[first - xx * n][second - yy * m];
  return res;
}
int main() {
  int q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", c[i] + 1);
  }
  for (int i = 1; i <= 2 * n; i++) {
    for (int j = 1; j <= 2 * m; j++) {
      if (i > n && j > m) {
        c[i][j] = c[i - n][j - m];
      } else if (i > n) {
        c[i][j] = ((c[i - n][j] - '0') ^ 1) + '0';
      } else if (j > m) {
        c[i][j] = ((c[i][j - m] - '0') ^ 1) + '0';
      }
    }
  }
  n *= 2, m *= 2;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum[i][j] = c[i][j] - '0';
      sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    }
  }
  while (q--) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    x1--;
    y1--;
    printf("%lld\n", dc(x1, y1) + dc(x2, y2) - dc(x2, y1) - dc(x1, y2));
  }
}
