#include<bits/stdc++.h>
using namespace std;
#define MAXN 2005
#define open(s) freopen( s".in", "r", stdin ), freopen( s".out", "w", stdout )
#define fp( i, b, e ) for ( int i(b), I(e); i <= I; ++i )
#define fd( i, b, e ) for ( int i(b), I(e); i >= I; --i )
#define go( i, b ) for ( int i(b), v(to[i]); i; v = to[i = nxt[i]] )
template<typename T> inline void cmax( T &x, T y ){ x < y ? x = y : x; }
template<typename T> inline void cmin( T &x, T y ){ y < x ? x = y : x; }
#define getchar() ( p1 == p2 && ( p1 = bf, p2 = bf + fread( bf, 1, 1 << 21, stdin ), p1 == p2 ) ? EOF : *p1++ )
char bf[1 << 21], *p1(bf), *p2(bf);
template<typename T>
inline void read( T &x ){ char t(getchar()), flg(0); x = 0;
	for ( ; !isdigit(t); t = getchar() ) flg = t == '-';
	for ( ; isdigit(t); t = getchar() ) x = x * 10 + ( t & 15 );
	flg ? x = -x : x;
}

clock_t t_bg, t_ed;

int N, M, Q;
int s[MAXN][MAXN];
int s1[MAXN][MAXN], s2[MAXN][MAXN];
#define sum( s, a, b, c, d ) ( s[c][d] + s[a-1][b-1] - s[c][b-1] - s[a-1][d] )

int main(){
	t_bg = clock();
	read(N), read(M), read(Q);
	fp( i, 1, N ) fp( j, 1, M ){
		while( (s[i][j] = getchar()) != '0' && s[i][j] != '1' );
		s[i][j] &= 1;
	}
	fp( i, 1, N ) fp( j, 1, M - 1 ) s1[i][j] = s1[i][j - 1] + s1[i - 1][j] - s1[i - 1][j - 1] + (s[i][j] & s[i][j + 1]);
	fp( i, 1, N - 1 ) fp( j, 1, M ) s2[i][j] = s2[i][j - 1] + s2[i - 1][j] - s2[i - 1][j - 1] + (s[i][j] & s[i + 1][j]);
	fp( i, 1, N ) fp( j, 1, M ) s[i][j] += s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1];
	while( Q-- ){
		int a, b, c, d;
		read(a), read(b), read(c), read(d);
		printf( "%d\n", sum(s, a, b, c, d) - sum(s1, a, b, c, d - 1) - sum(s2, a, b, c - 1, d) );
	}
	t_ed = clock();
	fprintf( stderr, "\n========info========\ntime : %.3f\n====================\n", (double)( t_ed - t_bg ) / CLOCKS_PER_SEC );
	return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int q = ri();
	std::string s[n];
	for (int i = 0; i < n; i++) std::cin >> s[i];
	
	std::vector<std::vector<int> > k(n + 1, std::vector<int>(m + 1));
	std::vector<std::vector<int> > yok(n, std::vector<int>(m + 1));
	std::vector<std::vector<int> > tat(n + 1, std::vector<int>(m));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i][j] == '1') {
				k[i + 1][j + 1]++;
				if (i + 1 < n && s[i + 1][j] == '1') yok[i + 1][j + 1]++;
				if (j + 1 < m && s[i][j + 1] == '1') tat[i + 1][j + 1]++;
			}
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= m; j++) {
			k[i + 1][j] += k[i][j];
			if (j < m) tat[i + 1][j] += tat[i][j];
			if (i + 1 < n) yok[i + 1][j] += yok[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < m; j++) {
			k[i][j + 1] += k[i][j];
			if (i < n) yok[i][j + 1] += yok[i][j];
			if (j + 1 < m) tat[i][j + 1] += tat[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= m; j++) {
			std::cerr << yok[i][j] << " ";
		}
		std::cerr << std::endl;
	}
	for (int i = 0; i < q; i++) {
		int x1 = ri() - 1, y1 = ri() - 1, x2 = ri() - 1, y2 = ri() - 1;
		int res = k[x2 + 1][y2 + 1] - k[x2 + 1][y1] - k[x1][y2 + 1] + k[x1][y1];
		res -= yok[x2][y2 + 1] - yok[x1][y2 + 1] - yok[x2][y1] + yok[x1][y1];
		res -= tat[x2 + 1][y2] - tat[x1][y2] - tat[x2 + 1][y1] + tat[x1][y1];
		std::cout << res << std::endl;
	}
	
	return 0;
}

