#include <bits/stdc++.h>
using namespace std;
long Mem[50][50][50][50];
long L[50][50];
long St[50];
long OO[50][50];
long O[50][50];
long N, M, Q;
long Solve(int x1, int y1, int x2, int y2) {
  long i, j, c, y, x, minn;
  if (Mem[x1][x2][y1][y2] != -1) {
    return Mem[x1][x2][y1][y2];
  }
  if (x1 == x2 && y1 == y2) {
    return 1 - L[x1][y2];
  }
  if (x1 == x2) {
    long ans = 0;
    c = 0;
    for (y = y1; y <= y2; y++) {
      if (L[x1][y] == 1) {
        c = 0;
        continue;
      }
      c += 1;
      ans += c;
    }
    Mem[x1][x2][y1][y2] = ans;
    return ans;
  }
  if (y1 == y2) {
    long ans = 0;
    c = 0;
    for (x = x1; x <= x2; x++) {
      if (L[x][y1] == 1) {
        c = 0;
        continue;
      }
      c += 1;
      ans += c;
    }
    Mem[x1][x2][y1][y2] = ans;
    return ans;
  }
  long ans = Solve(x1, y1, x2 - 1, y2 - 1);
  for (i = x1; i <= x2; i++) {
    if (L[i][y2] == 1) {
      St[i] = 0;
      continue;
    }
    St[i] = 0;
    if (y2 - 1 >= 0) {
      St[i] = O[i][y2 - 1];
      if (y2 - y1 < St[i]) {
        St[i] = y2 - y1;
      }
    }
    St[i] += 1;
    ans += St[i];
    minn = St[i - 1];
    for (j = i - 1; j >= x1; j--) {
      if (St[j] < minn) {
        minn = St[j];
      }
      ans += min(St[i], minn);
    }
  }
  for (i = y1; i < y2; i++) {
    if (L[x2][i] == 1) {
      St[i] = 0;
      continue;
    }
    St[i] = 0;
    if (x2 - 1 >= 0) {
      St[i] = OO[x2 - 1][i];
      if (x2 - x1 < St[i]) {
        St[i] = x2 - x1;
      }
    }
    St[i] += 1;
    ans += St[i];
    minn = St[i - 1];
    for (j = i - 1; j >= y1; j--) {
      if (St[j] < minn) {
        minn = St[j];
      }
      ans += min(St[i], minn);
    }
  }
  Mem[x1][x2][y1][y2] = ans;
  return ans;
}
int main() {
  cin >> N >> M >> Q;
  long a, b, c, d, o;
  string s;
  long i, j, k, q;
  for (i = 0; i < 45; i++) {
    for (j = 0; j < 45; j++) {
      for (k = 0; k < 45; k++) {
        for (o = 0; o < 45; o++) {
          Mem[i][j][k][o] = -1;
        }
      }
    }
  }
  for (i = 0; i < N; i++) {
    cin >> s;
    for (j = 0; j < M; j++) {
      L[i][j] = s[j] - '0';
    }
  }
  for (i = 0; i < N; i++) {
    c = 0;
    for (j = 0; j < M; j++) {
      if (L[i][j] == 0) {
        c += 1;
      } else {
        c = 0;
      }
      O[i][j] = c;
    }
  }
  for (i = 0; i < M; i++) {
    c = 0;
    for (j = 0; j < N; j++) {
      if (L[j][i] == 0) {
        c += 1;
      } else {
        c = 0;
      }
      OO[j][i] = c;
    }
  }
  for (q = 0; q < Q; q++) {
    cin >> a >> b >> c >> d;
    cout << Solve(a - 1, b - 1, c - 1, d - 1) << endl;
  }
  return 0;
}
