#include <bits/stdc++.h>
using namespace std;
int row[45][45][45], grid[45][45][45][45], ans[45][45][45][45];
string s[45];
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = j; k < m; k++) {
        if (j == k) {
          row[i][j][k] = (s[i][j] == '0');
          continue;
        }
        row[i][j][k] = row[i][j][k - 1] & (s[i][k] == '0');
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int _i = i; _i < n; _i++) {
        for (int _j = j; _j < m; _j++) {
          grid[i][j][_i][_j] = 1;
          for (int k = i; k <= _i; k++) grid[i][j][_i][_j] &= row[k][j][_j];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int _i = 0; _i < n; _i++) {
        for (int _j = 0; _j < m; _j++) {
          ans[i + 1][j + 1][_i + 1][_j + 1] =
              ans[i + 1][j + 1][_i + 1][_j] + ans[i + 1][j + 1][_i][_j + 1] +
              ans[i + 1][j][_i + 1][_j + 1] + ans[i][j + 1][_i + 1][_j + 1] -
              ans[i + 1][j + 1][_i][_j] - ans[i + 1][j][_i + 1][_j] -
              ans[i][j + 1][_i + 1][_j] - ans[i + 1][j][_i][_j + 1] -
              ans[i][j + 1][_i][_j + 1] - ans[i][j][_i + 1][_j + 1] +
              ans[i + 1][j][_i][_j] + ans[i][j + 1][_i][_j] +
              ans[i][j][_i + 1][_j] + ans[i][j][_i][_j + 1] -
              ans[i][j][_i][_j] + grid[i][j][_i][_j];
        }
      }
    }
  }
  int x, y, _x, _y;
  while (q--) {
    scanf("%d %d %d %d", &x, &y, &_x, &_y);
    x--, y--, _x--, _y--;
    int ret = ans[_x + 1][_y + 1][_x + 1][_y + 1] -
              ans[x][_y + 1][_x + 1][_y + 1] - ans[_x + 1][y][_x + 1][_y + 1] -
              ans[_x + 1][_y + 1][x][_y + 1] - ans[_x + 1][_y + 1][_x + 1][y] +
              ans[x][y][_x + 1][_y + 1] + ans[x][_y + 1][x][_y + 1] +
              ans[x][_y + 1][_x + 1][y] + ans[_x + 1][y][x][_y + 1] +
              ans[_x + 1][y][_x + 1][y] + ans[_x + 1][_y + 1][x][y] -
              ans[x][y][x][_y + 1] - ans[x][y][_x + 1][y] -
              ans[x][_y + 1][x][y] - ans[_x + 1][y][x][y] + ans[x][y][x][y];
    printf("%d\n", ret);
  }
  return 0;
}
