#include <bits/stdc++.h>
using namespace std;
string matr[40];
int dp[41][41][41][41];
int main() {
  string str;
  int m, n, q, t, u, v, j, sum, x1, y1, x2, y2, y, min;
  int arr[42];
  cin >> m >> n >> q;
  for (int i = 0; i < m; i++) {
    cin >> matr[i];
  }
  for (int j = 1; j <= 40; j++)
    for (int i = 0; i <= 40; i++) {
      dp[1][j][i][0] = 0;
      dp[j][1][0][i] = 0;
    }
  for (int sz2 = 2; sz2 <= m + n; sz2++)
    for (int x = 1; x <= m && x <= sz2; x++) {
      y = sz2 - x;
      if (y > n) continue;
      for (int sz = sz2; sz <= m + n; sz++) {
        for (int i = x; i <= m && i <= sz - 1; i++) {
          j = sz - i;
          if (j > n || j < y) continue;
          if (matr[i - 1][j - 1] == '1')
            sum = 0;
          else {
            sum = 0;
            min = y - 1;
            for (u = i - 1; u >= x - 1; u--) {
              if (matr[u][j - 1] != '0') break;
              for (v = j - 2; v >= min && v >= y - 1; v--) {
                if (matr[u][v] != '0') break;
              }
              min = v + 1;
              sum += (j - 1 - v);
            }
          }
          dp[x][y][i][j] = dp[x][y][i][j - 1] + dp[x][y][i - 1][j] -
                           dp[x][y][i - 1][j - 1] + sum;
        }
      }
    }
  while (q--) {
    cin >> x1 >> y1 >> x2 >> y2;
    cout << dp[x1][y1][x2][y2] << endl;
  }
  return 0;
}
