#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
using namespace std;
const int maxn = 1e3 + 10;
int n, m, q;
char ss[maxn][maxn];
int mp[maxn][maxn];
long long sum1[maxn][maxn];
long long sum2[maxn][maxn];
int t = 0;
long long change(int k, int x, int y) {
  if (x == 0 || y == 0) return 0;
  if (x / n == 0 && y / m == 0) {
    if (k == 1)
      return sum1[x][y];
    else
      return sum2[x][y];
  }
  if (x / n == 0 || y / m == 0) {
    if (x / n == 0) {
      int b = y / m;
      int d = 0;
      for (int j = 1; j; j = j * 2) {
        if (j > b) break;
        if (b >= j) d = j;
      }
      if (k == 1) {
        return sum2[x][m] * (d / 2) + sum1[x][m] * (d - d / 2) +
               change(0, x, y - d * m);
      } else {
        return sum1[x][m] * (d / 2) + sum2[x][m] * (d - d / 2) +
               change(1, x, y - d * m);
      }
    } else {
      int b = x / n;
      int d = 0;
      for (int j = 1; j; j = j * 2) {
        if (j > b) break;
        if (b >= j) d = j;
      }
      if (k == 1) {
        return sum2[n][y] * (d / 2) + sum1[n][y] * (d - d / 2) +
               change(0, x - d * n, y);
      } else {
        return sum1[n][y] * (d / 2) + sum2[n][y] * (d - d / 2) +
               change(1, x - d * n, y);
      }
    }
  }
  int a = x / n;
  int b = y / m;
  int c = 0;
  int d = 0;
  int aa = 0;
  int bb = 0;
  for (int j = (1 << 30); j >= 1; j = j / 2) {
    if (a >= j) {
      a -= j;
      c += j;
      aa++;
    }
    if (b >= j) {
      b -= j;
      d += j;
      bb++;
    }
  }
  if (k == 1) {
    long long w = 0;
    if (1ll * c * d % 2 == 1) {
      if ((aa + bb) % 2 == 0)
        w = sum1[n][m];
      else
        w = sum2[n][m];
    }
    return w + sum2[n][m] * (1ll * c * d / 2) + sum1[n][m] * (1ll * c * d / 2) +
           change((1 + bb % 2) % 2, x, y - d * m) +
           change((1 + aa % 2) % 2, x - c * n, d * m);
  } else {
    long long w = 0;
    if (1ll * c * d % 2 == 1) {
      if ((aa + bb) % 2 == 0)
        w = sum2[n][m];
      else
        w = sum1[n][m];
    }
    return w + sum1[n][m] * (1ll * c * d / 2) + sum2[n][m] * (1ll * c * d / 2) +
           change((bb % 2) % 2, x, y - d * m) +
           change((aa % 2) % 2, x - c * n, d * m);
  }
}
long long slove(int x, int y) { return change(1, x, y); }
int32_t main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%s", ss[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      mp[i + 1][j + 1] = ss[i][j] - '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum1[i][j] += sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1] +
                    (mp[i][j] == 1);
      sum2[i][j] += sum2[i - 1][j] + sum2[i][j - 1] - sum2[i - 1][j - 1] +
                    (mp[i][j] == 0);
    }
  }
  while (q--) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    long long ans = slove(x2, y2) - slove(x1 - 1, y2) - slove(x2, y1 - 1) +
                    slove(x1 - 1, y1 - 1);
    printf("%lld\n", ans);
  }
}
