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

long long N, M, Q;

long long ban[2005][2005];

long long node[2005][2005];
long long tate[2005][2005];
long long yoko[2005][2005];

long long x[200005];
long long y[200005];
long long z[200005];
long long w[200005];

void prenode(){
	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < M; j++){
			if(ban[i][j]){
				node[i+1][j+1] = 1;
			}
		}
	}
	for(long long i = 0; i < N; i++){
		node[i+1][0] += node[i][0];
	}

	for(long long i = 0; i < M; i++){
		node[0][i+1] += node[0][i];
	}

	for(long long i = 1; i <= N; i++){
		for(long long j = 1; j <= M; j++){
			node[i][j] += node[i-1][j] + node[i][j-1] - node[i-1][j-1];
		}
	}

	/*
	for(long long i = 0; i <= N; i++){
		for(long long j = 0; j <= M; j++){
			cout << node[i][j];
		}
		cout << endl;
	}
	*/
}

void pretate(){
	for(long long i = 1; i < N; i++){
		for(long long j = 0; j < M; j++){
			if(ban[i-1][j] && ban[i][j]){
				tate[i+1][j+1] = 1;
			}
		}
	}
	for(long long i = 0; i < N; i++){
		tate[i+1][0] += tate[i][0];
	}

	for(long long i = 0; i < M; i++){
		tate[0][i+1] += tate[0][i];
	}

	for(long long i = 1; i <= N; i++){
		for(long long j = 1; j <= M; j++){
			tate[i][j] += tate[i-1][j] + tate[i][j-1] - tate[i-1][j-1];
		}
	}

	/*
	for(long long i = 0; i <= N; i++){
		for(long long j = 0; j <= M; j++){
			cout << tate[i][j];
		}
		cout << endl;
	}
	*/
}

void preyoko(){
	for(long long i = 0; i < N; i++){
		for(long long j = 1; j < M; j++){
			if(ban[i][j-1] && ban[i][j]){
				yoko[i+1][j+1] = 1;
			}
		}
	}
	for(long long i = 0; i < N; i++){
		yoko[i+1][0] += yoko[i][0];
	}

	for(long long i = 0; i < M; i++){
		yoko[0][i+1] += yoko[0][i];
	}

	for(long long i = 1; i <= N; i++){
		for(long long j = 1; j <= M; j++){
			yoko[i][j] += yoko[i-1][j] + yoko[i][j-1] - yoko[i-1][j-1];
		}
	}

	/*
	for(long long i = 0; i <= N; i++){
		for(long long j = 0; j <= M; j++){
			cout << yoko[i][j];
		}
		cout << endl;
	}
	*/
}

long long cal(long long y1, long long x1, long long y2, long long x2){
	long long nnum;
	long long tnum;
	long long ynum;

	//cout << "y1 = " << y1 << " x1 = " << x1 << " y2 = " << y2 << " x2 = " << x2  << endl;

	//cout << "node[" << y2 << "][" << x2 << "] = " << node[y2][x2] << endl;
	//cout << "node[" << y2 << "][" << x1 << "] = " << node[y2][x1] << endl;
	//cout << "node[" << y1 << "][" << x2 << "] = " << node[y1][x2] << endl;
	//cout << "node[" << y1 << "][" << x1 << "] = " << node[y1][x1] << endl;

	nnum = node[y2][x2] - node[y2][x1] - node[y1][x2] + node[y1][x1];
	tnum = tate[y2][x2] - tate[y2][x1] - tate[y1+1][x2] + tate[y1+1][x1];
	ynum = yoko[y2][x2] - yoko[y2][x1+1] - yoko[y1][x2] + yoko[y1][x1+1];

	//cout << "nnum = " << nnum << endl;
	//cout << "tnum = " << tnum << endl;
	//cout << "ynum = " << ynum << endl;
	
	return nnum - tnum - ynum;
}

int main(){
	cin >> N >> M >> Q;
	for(long long i = 0; i < N; i++){
		string str;
		cin >> str;
		for(long long j = 0; j < str.size(); j++){
			if(str[j] == '1'){
				ban[i][j] = 1;
			}
		}
	}



	for(long long i = 0; i < Q; i++){
		cin >> x[i] >> y[i] >> z[i] >> w[i];
		x[i]--;y[i]--;z[i]--;w[i]--;
	}

	prenode();
	pretate();
	preyoko();

	for(long long i = 0; i < Q; i++){
		cout << cal(x[i], y[i], z[i] + 1, w[i] + 1) << endl;
	}
}


Measured memory_bytes: 133632