#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
bool isPrime(long long a) {
  long long i;
  for (i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      return 0;
    }
  }
  return (a != 1);
}
bool isPalindrom(const string &s, int l, int r) {
  for (int i = 0; i < (r - l + 1) / 2; i++) {
    if (s[l + i] != s[r - i]) {
      return 0;
    }
  }
  return 1;
}
template <class type1>
type1 gcd(type1 a, type1 b) {
  type1 t;
  while (b) {
    t = b;
    b = a % b;
    a = t;
  }
  return a;
}
long long positiveMod(long long v, long long md) {
  v = v % md;
  if (v < 0) {
    v += md;
  }
  return v;
}
string s;
long long n, m;
long long field[1005][1005];
long long pref[1005][1005];
long long st2[35];
long long getShapeType(long long x, long long y) {
  long long p = 0, i;
  for (i = 30; i >= 0; i--) {
    if (x > st2[i]) {
      x -= st2[i];
      p ^= 1;
    }
  }
  for (i = 30; i >= 0; i--) {
    if (y > st2[i]) {
      y -= st2[i];
      p ^= 1;
    }
  }
  return p;
}
long long getRes(long long x, long long y) {
  if (x == 0 || y == 0) {
    return 0;
  }
  long long res = 0;
  long long ta = x / n, tb = y / m;
  {
    res += ta * tb / 2 * n * m;
    if (ta * tb % 2 == 1) {
      long long mit = getShapeType(ta, tb);
      if (mit == 0) {
        res += pref[n][m];
      } else {
        res += n * m - pref[n][m];
      }
    }
  }
  {
    long long hight = x % n;
    res += tb / 2 * hight * m;
    if (tb % 2 == 1) {
      long long mit = getShapeType(ta + 1, tb);
      if (mit == 0) {
        res += pref[hight][m];
      } else {
        res += hight * m - pref[hight][m];
      }
    }
  }
  {
    long long width = y % m;
    res += ta / 2 * n * width;
    if (ta % 2 == 1) {
      long long mit = getShapeType(ta, tb + 1);
      if (mit == 0) {
        res += pref[n][width];
      } else {
        res += n * width - pref[n][width];
      }
    }
  }
  {
    long long mit = getShapeType(ta + 1, tb + 1);
    long long tx = x % n;
    long long ty = y % m;
    if (mit == 0) {
      res += pref[tx][ty];
    } else {
      res += tx * ty - pref[tx][ty];
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long i, j, a, b, c, d, q, x1, y1, x2, y2;
  cin >> n >> m >> q;
  for (i = 1; i <= n; i++) {
    cin >> s;
    for (j = 1; j <= m; j++) {
      field[i][j] = s[j - 1] - '0';
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      pref[i][j] =
          pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + field[i][j];
    }
  }
  st2[0] = 1;
  for (i = 1; i <= 30; i++) {
    st2[i] = st2[i - 1] * 2;
  }
  for (i = 0; i < q; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << getRes(x2, y2) - getRes(x2, y1 - 1) - getRes(x1 - 1, y2) +
                getRes(x1 - 1, y1 - 1)
         << "\n";
  }
  return 0;
}
