#include <bits/stdc++.h>
using namespace std;
inline char skipwhitespace() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t') ch = getchar();
  return ch;
}
void gi(int &x) {
  register int c = getchar();
  x = 0;
  int sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void gii(long long int &x) {
  register long long int c = getchar();
  x = 0;
  long long int sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void wi(int n) {
  int sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[10];
  int i = 9;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 10) printf("%c", buf[i]);
}
void wii(long long int n) {
  long long int sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[25];
  long long int i = 24;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 25) printf("%c", buf[i]);
}
int gs(char *s) {
  char ch = skipwhitespace();
  int n = 0;
  while ((ch != '\n' && ch != ' ' && ch != '\t')) {
    s[n++] = ch;
    ch = getchar();
  }
  s[n] = 0;
  return n;
}
void ws(char *s) {
  char *p = s;
  while (*p) {
    printf("%c", *p);
    p++;
  }
}
char c;
int a[50][50], ans[50][50][50][50], cnt[50][50];
int main() {
  int n, m, q;
  gi(n);
  gi(m);
  gi(q);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char c;
      scanf(" %c", &c);
      a[i][j] = c == '1';
    }
  for (int i1 = 0; i1 < n; i1++)
    for (int j1 = 0; j1 < m; j1++) {
      for (int i2 = i1; i2 <= n - 1; i2++)
        for (int j2 = j1; j2 <= m - 1; j2++) {
          int sum = 0;
          if (i2 == i1) {
            if (!a[i2][j2])
              cnt[i2][j2] = 1;
            else
              cnt[i2][j2] = 0;
            for (int k1 = j1; k1 <= j2; k1++) {
              for (int k2 = k1; k2 <= j2; k2++)
                if (!a[i2][k2])
                  sum++;
                else
                  break;
            }
            ans[i1][j1][i2][j2] = sum;
          } else {
            if (!a[i2][j2])
              cnt[i2][j2] = cnt[i2 - 1][j2] + 1;
            else
              cnt[i2][j2] = 0;
            for (int k1 = j1; k1 <= j2; k1++) {
              int x = numeric_limits<int>::max();
              for (int k2 = k1; k2 <= j2; k2++) {
                x = min(x, cnt[i2][k2]);
                if (x == 0) break;
                sum += x;
              }
            }
            ans[i1][j1][i2][j2] = sum + ans[i1][j1][i2 - 1][j2];
          }
        }
    }
  while (q--) {
    int i1, j1, i2, j2;
    gi(i1);
    gi(j1);
    gi(i2);
    gi(j2);
    i1--;
    j1--;
    i2--;
    j2--;
    wi(ans[i1][j1][i2][j2]);
    printf("\n");
  }
  return 0;
}
