#include <bits/stdc++.h>
const int N = 40 + 5;
int n, m, q, s[N][N], f[N][N][N][N], g[N][N][N][N];
int main(void) {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    char str[N];
    scanf("%s", str + 1);
    for (int j = 1; j <= m; ++j)
      s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1] + (str[j] == '1');
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      for (int x = i; x <= n; ++x)
        for (int y = j; y <= m; ++y)
          f[i][j][x][y] =
              +f[i][j][x - 1][y] + f[i][j][x][y - 1] - f[i][j][x - 1][y - 1] +
              (s[x][y] - s[x][j - 1] - s[i - 1][y] + s[i - 1][j - 1] == 0);
  for (int i = n; i; --i)
    for (int j = m; j; --j)
      for (int x = i; x <= n; ++x)
        for (int y = j; y <= m; ++y)
          g[i][j][x][y] = +g[i + 1][j][x][y] + g[i][j + 1][x][y] -
                          g[i + 1][j + 1][x][y] + f[i][j][x][y];
  while (q--) {
    int x1, y1, x2, y2;
    scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    printf("%d\n", g[x1][y1][x2][y2]);
  }
}
