#include <bits/stdc++.h>
using namespace std;

#define int long long
#define inf 1000000007LL

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

class Dinic {
public:
  vector<vector<pair<int, int>>> v;
  vector<int> e;

  vector<int> k;
  vector<int> j;

  void init(int n) {
    v = vector<vector<pair<int, int>>>(n);
    e = vector<int>();
    k = vector<int>(n);
    j = vector<int>(n);
  }
  void add_edge(int a, int b, int atob, int btoa = 0) {
    v[a].push_back(make_pair(b, e.size()));
    e.push_back(atob);
    v[b].push_back(make_pair(a, e.size()));
    e.push_back(btoa);
  }
  void dyk(int s) {
    for(auto& i : k) {
      i = inf;
    }
    queue<pair<int, int>> pq;
    pq.push(make_pair(0, s));
    while(!pq.empty()) {
      int w = pq.front().first;
      int b = pq.front().second;
      pq.pop();
      if(k[b] > w) {
        k[b] = w;
        for(auto i : v[b]) {
          if(e[i.second] > 0) {
            pq.push(make_pair(w + 1, i.first));
          }
        }
      }
    }
  }
  int dfs(int s, int t, int p, int c) {
    if(p == t) {
      return c;
    }
    int all = 0;
    while(c > all && j[p] < v[p].size()) {
      if(k[v[p][j[p]].first] == k[p] + 1) {
        int r = dfs(s, t, v[p][j[p]].first, min(c - all, e[v[p][j[p]].second]));
        e[v[p][j[p]].second] -= r;
        e[v[p][j[p]].second ^ 1] += r;
        if(r < c - all) {
          j[p]++;
        }
        all += r;
      }
      else {
        j[p]++;
      }
    }
    return all;
  }
  int solve(int s, int t) {
    int all = 0;
    while(1) {
      dyk(s);
      for(auto& i : j) {
        i = 0;
      }
      int r = dfs(s, t, s, inf);
      if(r == 0) {
        return all;
      }
      all += r;
    }
  }
};

class Rui {
public:
  int n, m;
  int d[2222][2222];

  void init(int nw, int mw) {
    n = nw;
    m = mw;
    trep(i, n) {
      trep(j, m) {
        d[i][j] = 0;
      }
    }
  }
  void add(int y, int x, int a) {
    d[y][x] += a;
  }
  void make() {
    rrep(i, n) {
      rrep(j, m) {
        d[i][j] += d[i][j + 1];
      }
      rep(j, m) {
        d[i][j] += d[i + 1][j];
      }
    }
  }
  int solve(int yb, int ye, int xb, int xe) {
    return d[yb][xb] - d[yb][xe] - d[ye][xb] + d[ye][xe];
  }
};

Rui me, t, y;

string s[2222];

signed main() {
  int n, m, q;
  cin >> n >> m >> q;
  rep(i, n) {
    cin >> s[i];
  }
  me.init(n, m);
  t.init(n, m + 1);
  y.init(n + 1, m);
  rep(i, n) {
    rep(j, m) {
      if(s[i][j] == '1') {
        me.add(i, j, 1);
      }
    }
  }
  rep(i, n) {
    rep(j, m - 1) {
      if(s[i][j] == '1' && s[i][j + 1] == '1') {
        t.add(i, j + 1, 1);
      }
    }
  }
  rep(i, n - 1) {
    rep(j, m) {
      if(s[i][j] == '1' && s[i + 1][j] == '1') {
        y.add(i + 1, j, 1);
      }
    }
  }
  me.make();
  t.make();
  y.make();
  rep(_, q) {
    int xb, yb, xl, yl;
    cin >> yb >> xb >> yl >> xl;
    xb--;
    xl--;
    yb--;
    yl--;
    int all = 0;
    all += t.solve(yb, yl + 1, xb + 1, xl + 1);
    all += y.solve(yb + 1, yl + 1, xb, xl + 1);
    cout << me.solve(yb, yl + 1, xb, xl + 1) - all << endl;
  }
}


Measured memory_bytes: 114432