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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 2000;
const int Q = 200000;

struct Input {
	int n, m, q;
	bool a[N][N];
	int xl[Q], xr[Q], yl[Q], yr[Q];
	
	bool read () {
		if (!(cin >> n >> m >> q)) {
			return 0;
		}
		string s;
		getline(cin, s);
		forn (i, n) {
			getline(cin, s);
			forn (j, m) {
				a[i][j] = (s[j] == '1');
			}
		}
		forn (i, q) {
			scanf("%d%d%d%d", &xl[i], &yl[i], &xr[i], &yr[i]);
			--xl[i];
			--yl[i];
		}
		return 1;
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	int ans[Q];
	
	void write () {
		forn (i, q) {
			printf("%d\n", ans[i]);
		}
	}
};


namespace Main {
	const int dx[4] = {1, 0, -1, 0};
	const int dy[4] = {0, 1, 0, -1};
	
	struct Solution: Data {
		bool u[N][N];
		int prx[N][N], pry[N][N];
		
		void dfs (int x, int y, int px, int py) {
			if (x < 0 || x >= n || y < 0 || y >= m) {
				return;
			}
			if (!a[x][y] || u[x][y]) {
				return;
			}
			u[x][y] = 1;
			prx[x][y] = px;
			pry[x][y] = py;
			
			forn (i, 4) {
				dfs(x + dx[i], y + dy[i], x, y);
			}
		}
		
		int sum[N + 1][N + 1];
		int sumu[N][N + 1], sumd[N][N + 1], suml[N + 1][N], sumr[N + 1][N];
		
		void solve () {
			memset(u, 0, sizeof u);
			memset(sum, 0, sizeof sum);
			forn (i, n) {
				forn (j, m) {
					sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
					if (a[i][j] && !u[i][j]) {
						sum[i + 1][j + 1]++;
						dfs(i, j, i, j);
					}
					if (!a[i][j]) {
						prx[i][j] = i;
						pry[i][j] = j;
					}
				}
			}
			memset(sumu, 0, sizeof sumu);
			memset(sumd, 0, sizeof sumd);
			memset(suml, 0, sizeof suml);
			memset(sumr, 0, sizeof sumr);
			forn (i, n) {
				forn (j, m) {
					sumu[i][j + 1] = sumu[i][j];
					if (prx[i][j] == i - 1) {
						sumu[i][j + 1]++;
					}
					sumd[i][j + 1] = sumd[i][j];
					if (prx[i][j] == i + 1) {
						sumd[i][j + 1]++;
					}
					suml[i + 1][j] = suml[i][j];
					if (pry[i][j] == j - 1) {
						suml[i + 1][j]++;
					}
					sumr[i + 1][j] = sumr[i][j];
					if (pry[i][j] == j + 1) {
						sumr[i + 1][j]++;
					}
				}
			}
			forn (i, q) {
				ans[i] = sum[xr[i]][yr[i]] - sum[xl[i]][yr[i]] - sum[xr[i]][yl[i]] + sum[xl[i]][yl[i]];
				ans[i] += sumu[xl[i]][yr[i]] - sumu[xl[i]][yl[i]];
				ans[i] += sumd[xr[i] - 1][yr[i]] - sumd[xr[i] - 1][yl[i]];
				ans[i] += suml[xr[i]][yl[i]] - suml[xl[i]][yl[i]];
				ans[i] += sumr[xr[i]][yr[i] - 1] - sumr[xl[i]][yr[i] - 1];
			}
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
			debug();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 123264