// ===== 2018/06/06 18:57:24 =====

// ../../../lib/template/includes.hpp

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>

// ../../../lib/template/const_value.hpp

template <typename T> constexpr T inf();
template <> constexpr int inf<int>() { return 1e9; }
template <> constexpr long long inf<long long>() { return 1e18; }
template <> constexpr long double inf<long double>() { return 1e30; }

template <typename T>
constexpr typename std::enable_if<std::is_arithmetic<T>::value, T>::type
zero() {
  return T(0);
}

const long double pi = acos(-1.0);

// ../../../lib/template/initialize.cpp

struct yes_no : std::numpunct<char> {
  string_type do_truename() const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

struct Initialize {
  Initialize() {
    std::locale loc(std::locale(), new yes_no);
    std::cout << std::boolalpha << std::setprecision(11) << std::fixed;
    std::cout.imbue(loc);
  }
};

const Initialize init;

// ../../../lib/template/macros.hpp

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

// ../../../lib/template/misc.hpp

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// ../../../lib/template/range.hpp

class range {
  class index_type {
    int x;

  public:
    index_type(int x_) : x(x_) {}
    int operator*() const { return x; }
    bool operator!=(index_type &r) { return x < r.x; }
    void operator++() { ++x; }
  };
  index_type i, n;

public:
  range(int n_) : i(0), n(n_) {}
  range(int i_, int n_) : i(i_), n(n_) {}
  index_type &begin() { return i; }
  index_type &end() { return n; }
};

// ../../../lib/template/typedef.hpp

using ll = long long;
using ld = long double;
using Point = std::complex<ld>;

// ../../../lib/template/template.cpp

using namespace std;

// C.cpp

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

int sum[2048][2048];
int vert[2048][2048];
int horz[2048][2048];

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<string> s(N);
  REP(i,N) cin >> s[i];
  REP(i,N) REP(j,M) {
    sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j]
      + (s[i][j] == '1');
  }
  REP(i,N-1) REP(j,M) {
    vert[i+1][j+1] = vert[i+1][j] + vert[i][j+1] - vert[i][j]
      + (s[i][j] == '1' && s[i+1][j] == '1');
  }
  REP(i,N) REP(j,M-1) {
    horz[i+1][j+1] = horz[i+1][j] + horz[i][j+1] - horz[i][j]
      + (s[i][j] == '1' && s[i][j+1] == '1');
  }
  REP(i,Q) {
    int l, u, r, b;
    cin >> u >> l >> b >> r; --l; --u;
    int res = sum[b][r] - sum[b][l] - sum[u][r] + sum[u][l];
    res -= vert[b-1][r] - vert[b-1][l] - vert[u][r] + vert[u][l];
    res -= horz[b][r-1] - horz[b][l] - horz[u][r-1] + horz[u][l];
    cout << res << endl;
  }
  return 0;
}
// ===== 2018/06/06 18:57:24 =====



Measured memory_bytes: 55040