#include <bits/stdc++.h>
typedef int arr[44];
typedef int mtx[44][44];
typedef int cube[44][44][44];
typedef int super[44][44][44][44];
int n, m, q;
char temp[44];
arr s;
mtx row;
super tot, up;
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%s", temp);
    row[i][0] = 0;
    for (int j = 0; j < m; j++) row[i][j + 1] = row[i][j] + temp[j] - '0';
  }
  for (int l = 1; l <= m; l++) {
    for (int r = l; r <= m; r++) {
      s[0] = 0;
      for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] + row[i][r] - row[i][l - 1];
      }
      for (int i = 1, j; i <= n; i++) {
        int temp = 0;
        for (j = i - 1; j >= 0; j--) {
          if (s[j] != s[i]) {
            for (; j >= 0; j--) {
              up[l][r][i][j + 1] = temp;
            }
            break;
          } else {
            temp = up[l][r][i][j + 1] = i - j;
          }
        }
      }
    }
  }
  for (int l = 1; l <= m; l++) {
    for (int r = l; r <= m; r++) {
      for (int j = 1; j <= n; j++) {
        int temp = 0;
        for (int i = j; i <= n; i++) {
          for (int x = l; x <= r; x++) {
            for (int y = x; y <= r; y++) {
              temp += up[x][y][i][j];
            }
          }
          tot[l][r][i][j] = temp;
        }
      }
    }
  }
  int a, b, c, d;
  while (q--) {
    scanf("%d%d%d%d", &a, &b, &c, &d);
    printf("%d\n", tot[b][d][c][a]);
  }
}
