#include <bits/stdc++.h>
using namespace std;
int rec[40][40][40][40], con[40][40][40][40], r[40][40];
int main() {
  int n, m, q, a, c, b, d, i, j, k, l;
  string s[50];
  scanf("%d %d %d", &n, &m, &q);
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      r[i][j] = s[i][j] - '0';
    }
  }
  rec[0][0][0][0] = r[0][0];
  for (j = 1; j < m; j++) {
    rec[0][0][0][j] = rec[0][0][0][j - 1] + r[0][j];
  }
  for (i = 1; i < n; i++) {
    rec[0][0][i][0] = rec[0][0][i - 1][0] + r[i][0];
    for (j = 1; j < m; j++) {
      rec[0][0][i][j] = rec[0][0][i - 1][j] + rec[0][0][i][j - 1] -
                        rec[0][0][i - 1][j - 1] + r[i][j];
    }
  }
  for (j = 1; j < m; j++) {
    for (k = 0; k < n; k++) {
      for (l = j; l < m; l++) {
        rec[0][j][k][l] = rec[0][0][k][l] - rec[0][0][k][j - 1];
      }
    }
  }
  for (i = 1; i < n; i++) {
    for (k = i; k < n; k++) {
      for (l = 0; l < m; l++) {
        rec[i][0][k][l] = rec[0][0][k][l] - rec[0][0][i - 1][l];
      }
    }
  }
  for (i = 1; i < n; i++) {
    for (j = 1; j < m; j++) {
      for (k = i; k < n; k++) {
        for (l = j; l < m; l++) {
          rec[i][j][k][l] = rec[0][0][k][l] - rec[0][0][i - 1][l] -
                            rec[0][0][k][j - 1] + rec[0][0][i - 1][j - 1];
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      for (k = i; k < n; k++) {
        for (l = j; l < m; l++) {
          if (rec[i][j][k][l] == 0)
            rec[i][j][k][l] = 1;
          else
            rec[i][j][k][l] = 0;
        }
      }
    }
  }
  for (a = 0; a < n; a++) {
    for (b = 0; b < m; b++) {
      con[a][b][a][b] = rec[a][b][a][b];
      for (k = a + 1; k < n; k++) {
        con[a][b][k][b] = con[a][b][k - 1][b];
        for (i = a; i <= k; i++) {
          con[a][b][k][b] += rec[i][b][k][b];
        }
      }
      for (l = b + 1; l < m; l++) {
        con[a][b][a][l] = con[a][b][a][l - 1];
        for (j = b; j <= l; j++) {
          con[a][b][a][l] += rec[a][j][a][l];
        }
      }
      for (k = a + 1; k < n; k++) {
        for (l = b + 1; l < m; l++) {
          con[a][b][k][l] = con[a][b][k - 1][l] + con[a][b][k][l - 1] -
                            con[a][b][k - 1][l - 1];
          for (i = a; i <= k; i++) {
            for (j = b; j <= l; j++) {
              con[a][b][k][l] += rec[i][j][k][l];
            }
          }
        }
      }
    }
  }
  for (i = 0; i < q; i++) {
    scanf("%d %d %d %d", &a, &b, &c, &d);
    printf("%d\n", con[a - 1][b - 1][c - 1][d - 1]);
  }
}
