#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int h[45][45][45][45];
char a[45][45];
int main(int argc, char *argv[]) {
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int o = i; o < n; o++)
        for (int k = j; k < m; k++) {
          if (o == i || h[i][j][o - 1][k] == 1)
            if (k == j || h[i][j][o][k - 1] == 1)
              if (a[o][k] == '0') h[i][j][o][k]++;
        }
  for (int i = n - 1; i >= 0; i--)
    for (int j = m - 1; j >= 0; j--)
      for (int o = i; o < n; o++)
        for (int k = j; k < m; k++)
          h[i][j][o][k] += h[i + 1][j][o][k] * (i + 1 <= o) +
                           h[i][j + 1][o][k] * (j + 1 <= k) -
                           h[i + 1][j + 1][o][k] * (i + 1 <= o) * (j + 1 <= k);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int o = i; o < n; o++)
        for (int k = j; k < m; k++) {
          if (i + 1 <= o) h[i][j][o][k] += h[i][j][o - 1][k];
          if (j <= k - 1) h[i][j][o][k] += h[i][j][o][k - 1];
          if (i + 1 <= o && j <= k - 1) h[i][j][o][k] -= h[i][j][o - 1][k - 1];
        }
  for (int i = 0; i < q; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    cout << h[a][b][c][d] << endl;
  }
  return 0;
}
