#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e3+5;
int n, m, q;
char s[N][N];
int f[N][N], g[N][N], h[N][N];
void add(int (*s)[N], int x, int y, int d) { s[x][y] = s[x][y-1]+s[x-1][y]-s[x-1][y-1]+d; }
int ask(int (*s)[N], int x1, int y1, int x2, int y2) { return s[x2][y2]+s[x1-1][y1-1]-s[x1-1][y2]-s[x2][y1-1]; }
int main()
{
    n = read(), m = read(), q = read();
    for(int i = 1; i <= n; ++i) scanf("%s", s[i]+1);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            add(f, i, j, s[i][j] == '1'),
            add(g, i, j, s[i][j] == '1'&&s[i-1][j] == '1'),
            add(h, i, j, s[i][j] == '1'&&s[i][j-1] == '1');
    while(q--)
    {
        int x1 = read(), y1 = read(), x2 = read(), y2 = read();
        printf("%d\n", ask(f, x1, y1, x2, y2)-ask(g, x1+1, y1, x2, y2)-ask(h, x1, y1+1, x2, y2));
    }
    return 0;
}