#include <bits/stdc++.h>
using namespace std;
int f[41][41][41][41];
int s[41][41];
int m, n, q;
int a[41][41];
void input() {
  scanf("%d%d%d\n", &m, &n, &q);
  for (int i = (1), _b = (m); i <= _b; i++) {
    string inp;
    getline(cin, inp);
    for (int j = (1), _b = (n); j <= _b; j++)
      a[i][j] = inp[j - 1] - '0',
      s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
  }
}
void solve() {
  for (int i = (1), _b = (m); i <= _b; i++)
    for (int j = (1), _b = (n); j <= _b; j++)
      for (int x = (1), _b = (i); x <= _b; x++)
        for (int y = (1), _b = (j); y <= _b; y++)
          f[m - x + 1][n - y + 1][i][j] =
              (s[i][j] - s[i][y - 1] - s[x - 1][j] + s[x - 1][y - 1] == 0);
  for (int i = (1), _b = (m); i <= _b; i++)
    for (int j = (1), _b = (n); j <= _b; j++)
      for (int x = (1), _b = (m); x <= _b; x++)
        for (int y = (1), _b = (n); y <= _b; y++)
          f[i][j][x][y] +=
              f[i][j][x][y - 1] + f[i][j][x - 1][y] + f[i][j - 1][x][y] +
              f[i - 1][j][x][y] - f[i - 1][j - 1][x][y] -
              f[i - 1][j][x][y - 1] - f[i][j][x - 1][y - 1] -
              f[i][j - 1][x - 1][y] - f[i - 1][j][x - 1][y] -
              f[i][j - 1][x][y - 1] + f[i - 1][j - 1][x - 1][y] +
              f[i - 1][j][x - 1][y - 1] + f[i - 1][j - 1][x][y - 1] +
              f[i][j - 1][x - 1][y - 1] - f[i - 1][j - 1][x - 1][y - 1];
}
void output() {
  for (int i = (1), _b = (q); i <= _b; i++) {
    int X1, X2, Y1, Y2;
    scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
    printf("%d\n", f[m - X1 + 1][n - Y1 + 1][X2][Y2]);
  }
}
int main() {
  clock_t timestart, timeend;
  timestart = clock();
  input();
  solve();
  output();
  timeend = clock();
  return 0;
}
