#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <string.h>
#define ll long long

using namespace std;

const int MAXN = 2000;

int row, col, q;
char area[MAXN + 5][MAXN + 5];
int pref[5][MAXN + 5][MAXN + 5];

int main(){
	
	cin >> row >> col >> q;
	for(int i = 1; i <= row; i ++){
		for(int j = 1; j <= col; j ++){
			cin >> area[i][j];
		}
	}
	for(int k = 1; k <= 3; k ++){
		for(int i = 1; i <= row; i ++){
			for(int j = 1; j <= col; j ++){
				pref[k][i][j] = pref[k][i - 1][j] 
					+ pref[k][i][j - 1] - pref[k][i - 1][j - 1];
				if(k == 1)pref[k][i][j] += (area[i][j] - '0');
				else if(k == 2){
					if(area[i][j - 1] == '1' && area[i][j] == '1')
						pref[k][i][j] += 1;
				}else{
					if(area[i - 1][j] == '1' && area[i][j] == '1')
						pref[k][i][j] += 1;
				}
			}
		}
	}
	for(int i = 1; i <= q; i ++){
		int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
		int ans = 0;
		for(int j = 1; j <= 3; j ++){
			int cur = 0;
			if(j == 1) cur = pref[j][r2][c2] - pref[j][r1 - 1][c2] - 
						pref[j][r2][c1 - 1] + pref[j][r1 - 1][c1 - 1];
			if(j == 2) cur = pref[j][r2][c2] - pref[j][r1 - 1][c2] - 
						pref[j][r2][c1] + pref[j][r1 - 1][c1];
			if(j == 3) cur = pref[j][r2][c2] - pref[j][r1][c2] -
						pref[j][r2][c1 - 1] + pref[j][r1][c1 - 1];
			// cout << j <<" "<< cur << endl;
			if(j == 1)ans += cur;
			else ans -= cur;
		}
		cout << ans << endl;
	}

	return 0;
}