#include <bits/stdc++.h>
using namespace std;
const int NMAX = 40;
int N, M, Q;
int sp[NMAX + 2][NMAX + 2], v[NMAX + 2][NMAX + 2];
int d[NMAX + 2][NMAX + 2][NMAX + 2][NMAX + 2];
int meh[NMAX + 2][NMAX + 2][NMAX + 2][NMAX + 2];
bool OK(int l1, int l2, int c1, int c2) {
  int a = l2, x = l1;
  int b = c2, y = c1;
  int sum = sp[a][b] - sp[a][y - 1] - sp[x - 1][b] + sp[x - 1][y - 1];
  return sum == 0;
}
int split_lin(int a, int b, int x, int y) {
  return d[a + 1][b][x][y] + d[a][b - 1][x][y] - d[a + 1][b - 1][x][y] +
         OK(a, b, x, y);
}
int split_col(int a, int b, int x, int y) {
  return d[a][b][x + 1][y] + d[a][b][x][y - 1] - d[a][b][x + 1][y - 1] +
         OK(a, b, x, y);
}
int split(int a, int b, int x, int y) {
  int A = a + 1, B = b - 1, X = x + 1, Y = y - 1;
  return d[A][b][x][y] + d[a][B][x][y] + d[a][b][X][y] + d[a][b][x][Y] -
         d[A][B][x][y] - d[A][b][X][y] - d[A][b][x][Y] - d[a][B][X][y] -
         d[a][B][x][Y] - d[a][b][X][Y] + d[A][B][X][y] + d[A][B][x][Y] +
         d[A][b][X][Y] + d[a][B][X][Y] - d[A][B][X][Y];
}
int main() {
  cin >> N >> M >> Q;
  for (int i = 1; i <= N; ++i) {
    string str;
    cin >> str;
    for (int j = 1; j <= M; ++j) {
      v[i][j] = (str[j - 1] == '1');
      sp[i][j] = v[i][j] + sp[i - 1][j] + sp[i][j - 1] - sp[i - 1][j - 1];
    }
  }
  for (int dx = 0; dx < N; ++dx) {
    for (int dy = 0; dy < M; ++dy) {
      for (int a = 1; a <= N; ++a) {
        if (a + dx > N) break;
        for (int x = 1; x <= M; ++x) {
          if (x + dy > M) break;
          int b = a + dx;
          int y = x + dy;
          if (dx == 0) {
            meh[a][b][x][y] = OK(a, b, x, y);
          } else if (dx == 1) {
            meh[a][b][x][y] =
                OK(a, b, x, y) + OK(a + 1, b, x, y) + OK(a, b - 1, x, y);
          } else if (dx >= 2) {
            meh[a][b][x][y] = meh[a][b - 1][x][y] + meh[a + 1][b][x][y] -
                              meh[a + 1][b - 1][x][y];
          }
        }
      }
    }
  }
  for (int dx = 0; dx < N; ++dx) {
    for (int dy = 0; dy < M; ++dy) {
      for (int a = 1; a <= N; ++a) {
        if (a + dx > N) break;
        for (int x = 1; x <= M; ++x) {
          if (x + dy > M) break;
          int b = a + dx;
          int y = x + dy;
          if (dx == 0) {
            if (dy == 0)
              d[a][b][x][y] = OK(a, b, x, y);
            else if (dy == 1)
              d[a][b][x][y] = OK(a, b, x, x) + OK(a, b, y, y) + OK(a, b, x, y);
            else if (dy >= 2) {
              d[a][b][x][y] = split_col(a, b, x, y);
            }
          } else if (dx == 1) {
            if (dy == 0)
              d[a][b][x][y] = OK(a, a, x, y) + OK(b, b, x, y) + OK(a, b, x, y);
            else if (dy == 1) {
              d[a][b][x][y] = OK(a, a, x, x) + OK(b, b, x, x) + OK(a, a, y, y) +
                              OK(b, b, y, y) + OK(a, b, x, x) + OK(a, b, y, y) +
                              OK(a, a, x, y) + OK(b, b, x, y) + OK(a, b, x, y);
            } else if (dy >= 2) {
              d[a][b][x][y] =
                  split_col(a, b, x, y) + OK(a, a, x, y) + OK(b, b, x, y);
            }
          } else if (dx >= 2) {
            if (dy == 0)
              d[a][b][x][y] = split_lin(a, b, x, y);
            else if (dy == 1)
              d[a][b][x][y] =
                  split_lin(a, b, x, y) + OK(a, b, x, x) + OK(a, b, y, y);
            else if (dy >= 2) {
              d[a][b][x][y] = split(a, b, x, y) + OK(a, b, x, y);
            }
          }
        }
      }
    }
  }
  while (Q--) {
    int a, b, c, d1;
    cin >> a >> b >> c >> d1;
    cout << d[a][c][b][d1] << '\n';
  }
  return 0;
}
