#include <bits/stdc++.h>
using namespace std;
int n, m, q;
bool isrc[50][50][50][50];
int rcc[50][50][50][50];
int gc[50][50];
char s[50];
int calc(int x, int y, int u, int w) {
  if (rcc[x][y][u][w] != -1) {
    return rcc[x][y][u][w];
  }
  if (x > u || y > w) {
    return 0;
  }
  rcc[x][y][u][w] =
      calc(x + 1, y, u, w) + calc(x, y, u - 1, w) - calc(x + 1, y, u - 1, w);
  for (int i = y; i < w + 1; i += 1) {
    for (int j = i; j < w + 1; j += 1) {
      rcc[x][y][u][w] += isrc[x][i][u][j];
    }
  }
  return rcc[x][y][u][w];
}
int main(int argc, char *argv[]) {
  int v;
  int a, b, c, d;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n + 1; i += 1) {
    for (int j = 0; j < m + 1; j += 1) {
      for (int k = 0; k < n + 1; k += 1) {
        for (int l = 0; l < m + 1; l += 1) {
          isrc[i][j][k][l] = false;
          rcc[i][j][k][l] = -1;
        }
      }
    }
  }
  for (int i = 1; i < n + 1; i += 1) {
    v = 0;
    scanf("%s", s + 1);
    for (int j = 1; j < m + 1; j += 1) {
      if (s[j] == '1') {
        v++;
      }
      gc[i][j] = gc[i - 1][j] + v;
    }
  }
  for (int i = 1; i < n + 1; i += 1) {
    for (int j = 1; j < m + 1; j += 1) {
      for (int k = i; k < n + 1; k += 1) {
        for (int l = j; l < m + 1; l += 1) {
          if (gc[k][l] + gc[i - 1][j - 1] == gc[k][j - 1] + gc[i - 1][l]) {
            isrc[i][j][k][l] = true;
          }
        }
      }
    }
  }
  for (int i = 1; i < q + 1; i += 1) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", calc(a, b, c, d));
  }
  return 0;
}
