#include <bits/stdc++.h>
using namespace std;
int n, m, t, sum[41][41][41][41], g[41][41][41][41];
char s[100];
bool ok[41][41], f[41][41][41][41];
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s);
    for (int j = 1; j <= m; j++)
      if (s[j - 1] == '0')
        ok[i][j] = true;
      else
        ok[i][j] = false;
  }
  memset(f, false, sizeof(f));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (ok[i][j]) f[i][j][i][j] = true;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (ok[i][j]) {
        for (int k = j + 1; k <= m; k++)
          if (ok[i][k])
            f[i][j][i][k] = true;
          else
            break;
        for (int k = i + 1; k <= n; k++)
          if (ok[k][j])
            f[i][j][k][j] = true;
          else
            break;
        for (int k = i + 1; k <= n; k++)
          for (int l = j + 1; l <= m; l++)
            if (f[i][j][k - 1][l] && f[i][j][k][l - 1] && ok[k][l])
              f[i][j][k][l] = true;
      }
  memset(g, false, sizeof(g));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = i; k <= n; k++)
        for (int l = j; l <= m; l++)
          g[i][j][k][l] = g[i - 1][j][k][l] + g[i][j - 1][k][l] -
                          g[i - 1][j - 1][k][l] + f[i][j][k][l];
  memset(sum, false, sizeof(sum));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      for (int k = i; k <= n; k++)
        for (int l = j; l <= m; l++)
          sum[i][j][k][l] = sum[i][j][k - 1][l] + sum[i][j][k][l - 1] -
                            sum[i][j][k - 1][l - 1] + g[k][l][k][l] +
                            g[i - 1][j - 1][k][l] - g[k][j - 1][k][l] -
                            g[i - 1][l][k][l];
  while (t--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", sum[a][b][c][d]);
  }
}
