#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;
typedef unsigned long long ull;

#define F first
#define S second
#define en end()
#define bg begin()
#define rev reverse
#define mp make_pair
#define pb push_back
#define y1 y1234567890
#define um unordered_map                         
#define all(x) x.bg, x.en
#define sqr(x) ((x) * (x))
#define sz(x) (int)x.size()

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;

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

const int N = 2005;

char c[N][N];
int n, m, q, sum[N][N], u[N][N], l[N][N];

inline int getsum(int x, int y, int xx, int yy) {
	return sum[xx][yy] - sum[x - 1][yy] - sum[xx][y - 1] + sum[x - 1][y - 1];
}

inline int getu(int x, int y, int xx, int yy) {
	return u[xx][yy] - u[x - 1][yy] - u[xx][y - 1] + u[x - 1][y - 1];
}

inline int getl(int x, int y, int xx, int yy) {
	return l[xx][yy] - l[x - 1][yy] - l[xx][y - 1] + l[x - 1][y - 1];
}

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//cin.tie(NULL);
	//cout.tie(NULL);
	//ios_base::sync_with_stdio(false);

	scanf("%d %d %d", &n, &m, &q);

	for (int i = 1; i <= n; i++) {
		scanf("%s", c[i] + 1);
		for (int j = 1; j <= m; j++) {
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + c[i][j] - '0';
			u[i][j] = u[i - 1][j] + u[i][j - 1] - u[i - 1][j - 1];
			l[i][j] = l[i - 1][j] + l[i][j - 1] - l[i - 1][j - 1];
			if (c[i][j] == '1') {
				if (i != 1 && c[i - 1][j] == '1')
					u[i][j]++;
				if (j != 1 && c[i][j - 1] == '1')
					l[i][j]++;
			}
		}
	}

	for (int i = 1; i <= q; i++) {
		int x, y, xx, yy;
		scanf("%d %d %d %d", &x, &y, &xx, &yy);
		int res = getsum(x, y, xx, yy);
		if (x < xx)
			res -= getu(x + 1, y, xx, yy);
		if (y < yy)
			res -= getl(x, y + 1, xx, yy);
		printf("%d\n", res);
	}
	        
	return 0;
}
