#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};

int main()
{
	ios_init();
	int n,m,q;
	while(cin >> n >> m >> q) {
		using vi = vector<int>;
		vector<string> s(n);
		REP(i,n) cin >> s[i];
		vector<vector<vi>> imo(4,vector<vi>(n+1,vi(m+1)));
		vector<vector<vi>> in(4,vector<vi>(n,vi(m)));
		auto check = [&](int x, int y) -> bool{
			return 0 <= x and x < n and 0 <= y and y < m;
		};
		vector<vector<bool>> used(n,vector<bool>(m,false));
		vector<vector<int>> imos(n+1,vector<int>(m+1));
		function<void(int,int)> dfs = 
		[&](int x, int y){
			bool f = true;
			REP(k,4){
				used[x][y] = true;
				int nx = x+dx[k];
				int ny = y+dy[k];
				// DEBUG(nx); DEBUG(ny);
				if(check(nx,ny) and s[nx][ny] == '1' and !used[nx][ny]){
					in[k][nx][ny]++;
					dfs(nx,ny);
					f = false;
				}
			}
			// if(f){
			// 	DEBUG(x); DEBUG(y);
			// 	if(imos[x+1][y+1] == 0) imos[x+1][y+1]++;
			// }
		};
		REP(i,n) REP(j,m){
			if(used[i][j] or s[i][j] == '0') continue;
			if(imos[i+1][j+1] == 0) imos[i+1][j+1]++;
			dfs(i,j);
			DEBUG(i); DEBUG(j);
			REP(i,n+1) dpite(ALL(imos[i]));
			DEBUG(endl);
			REP(i,n) dpite(ALL(used[i]));
			DEBUG(endl);
		}
		REP(i,n) REP(j,m+1){
			imos[i+1][j] += imos[i][j];
		}

		REP(j,m) REP(i,n+1){
			imos[i][j+1] += imos[i][j];
		}
		REP(i,n+1) dpite(ALL(imos[i]));
		
		for(auto&& e : {0,2}) {
			REP(j,m) REP(i,n){
				imo[e][i][j+1] = imo[e][i][j]+in[e][i][j];
			}
		}
		for(auto&& e : {1,3}) {
			REP(i,n) REP(j,m){
				imo[e][i+1][j] = imo[e][i][j]+in[e][i][j];
			}
		}
		DEBUG(endl);
		REP(k,4){
			REP(i,n) dpite(ALL(in[k][i]));
			DEBUG(endl);
		}
		REP(_,q){
			int x1,x2,y1,y2;
			cin >> x1 >> y1 >> x2 >> y2;
			x1--; y1--; //x2--; y2--;
			int ans = 0;
			ans += imos[x2][y2]-imos[x1][y2]-imos[x2][y1]+imos[x1][y1];
			DEBUG(ans);
			ans += imo[2][x1][y2]-imo[2][x1][y1];
			DEBUG(ans);
			ans += imo[0][x2-1][y2]-imo[0][x2-1][y1];
			DEBUG(ans);
			ans += imo[3][x2][y2-1]-imo[3][x1][y2-1];
			DEBUG(ans);
			ans += imo[1][x2][y1]-imo[1][x1][y1];
			DEBUG(ans);
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 151424