#include <bits/stdc++.h>
using namespace std;
int *mem, *rl, n, m;
char mp[41][41];
int right_left(int r, int c, int rmin, int cmin) {
  int index = (rmin - 1) * m * n * m + (cmin - 1) * n * m + (r - 1) * m + c - 1;
  if (rl[index] != -1)
    return rl[index];
  else {
    int len = r - rmin + 1, *tw = new int[len], ans = 0, mini;
    memset(tw, 0, len * 4);
    for (int i = 0; i < len; i++) {
      int j = 0;
      while (mp[r - i][c - j] == '0' && j <= c - cmin) {
        tw[i]++;
        j++;
      }
    }
    mini = tw[0];
    for (int i = 0; i < len; i++) {
      if (mini > tw[i]) mini = tw[i];
      ans += mini;
    }
    delete[] tw;
    return rl[index] = ans;
  }
}
int f(int a, int b, int c, int d) {
  int index = (a - 1) * m * n * m + (b - 1) * n * m + (c - 1) * m + d - 1;
  if (mem[index] != -1)
    return mem[index];
  else {
    int ans = 0;
    for (int row = a; row <= c; row++)
      for (int col = b; col <= d; col++) ans += right_left(row, col, a, b);
    return mem[index] = ans;
  }
}
int main() {
  int cas, a, b, c, d;
  for (int i = 0; i < 41; i++) mp[i][0] = mp[0][i] = '1';
  while (cin >> n >> m >> cas) {
    mem = new int[n * m * n * m];
    rl = new int[n * m * n * m];
    memset(mem, -1, n * m * n * m * 4);
    memset(rl, -1, n * m * n * m * 4);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cin >> mp[i][j];
    while (cas--) {
      cin >> a >> b >> c >> d;
      (cout << f(a, b, c, d) << endl);
    }
  }
  return 0;
}
