#include <bits/stdc++.h>

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename a>
struct S022 {
  std::vector<std::vector<a>> xs;
  S022(const std::vector<std::vector<a>>& ys) : xs(ys.size() + 1) {
    for(long i = 0; i < (long)xs.size(); ++i) {
      xs[i].resize(ys[0].size() + 1);
    }
    long n = (long)xs.size();
    long m = (long)xs[0].size();
    for(long i = 0; i < (long)xs[0].size(); ++i) xs[0][i] = 0;
    for(long i = 0; i < (long)xs.size(); ++i) xs[i][0] = 0;
    for(long i = 1; i < n; ++i) {
      for(long j = 1; j < m; ++j) {
        xs[i][j] = xs[i-1][j] + xs[i][j-1] - xs[i-1][j-1] + ys[i-1][j-1];
      }
    }
  }
  a f(long x1, long y1, long x2, long y2) {
    return xs[y2][x2] - xs[y1][x2] - xs[y2][x1] + xs[y1][x1];
  }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, m, q;
      scan(n, m, q);
      std::vector<std::string> field(n);
      for(long i = 0; i < n; ++i) scan(field[i]);
      std::vector<std::vector<long>> xss(n);
      // R D L U
      const long dx[] = {1, 0, -1, 0};
      const long dy[] = {0, 1, 0, -1};
      for(long y = 0; y < n; ++y) {
         for(long x = 0; x < m; ++x) {
            xss[y].push_back(field[y][x] == '1' ? 1 : 0);
         }
      }
      S022<long> blueCount(xss);
      std::vector<std::vector<long>> yoko;
      yoko.resize(n);
      for(long y = 0; y < n; ++y) {
         for(long x = 0; x < m; ++x) {
            long count = 0;
            long nx = x;
            long ny = y + 1;
            if( 0 <= nx and nx < m and 0 <= ny and ny < n ) {
               if( field[y][x] == '1' and field[ny][nx] == '1' ) count = 1;
            }
            yoko[y].push_back(count == 1 ? 1 : 0);
         }
      }
      S022<long> yokoCount(yoko);
      std::vector<std::vector<long>> tate;
      tate.resize(n);
      for(long y = 0; y < n; ++y) {
         for(long x = 0; x < m; ++x) {
            long count = 0;
            long nx = x + 1;
            long ny = y;
            if( 0 <= nx and nx < m and 0 <= ny and ny < n ) {
               if( field[y][x] == '1' and field[ny][nx] == '1' ) count = 1;
            }
            tate[y].push_back(count == 1 ? 1 : 0);
         }
      }
      S022<long> tateCount(tate);
      for(long i = 0; i < q; ++i) {
         long x1, y1, x2, y2;
         scan(y1, x1, y2, x2);
         // dumpll(x1, y1);
         // dumpll(x2, y2);
         long bc = blueCount.f(x1 - 1, y1 - 1, x2, y2);
         long yc = yokoCount.f(x1 - 1, y1 - 1, x2, y2 - 1);
         long tc = tateCount.f(x1 - 1, y1 - 1, x2 - 1, y2);
         // dumplll(bc, yc, tc);
         printf("%ld\n", bc - (yc + tc));
         // long leafs = leafCount.f(x1 - 1, y1 - 1, x2, y2);
         // long cuts =
         //    cutR.f(x2 - 1, y1 - 1, x2, y2) +
         //    cutD.f(x1 - 1, y2 - 1, x2, y2) +
         //    cutL.f(x1 - 1, y1 - 1, x1, y2) +
         //    cutU.f(x1 - 1, y1 - 1, x2, y1);
         // dumpll(leafs, cuts);
         // printf("%ld\n", (leafs + cuts) / 2);
      }
   }
};



int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}


// struct Solver {
//    Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
//    ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
//    void solve() {
//       long n, m, q;
//       scan(n, m, q);
//       std::vector<std::string> field(n);
//       for(long i = 0; i < n; ++i) scan(field[i]);
//       std::vector<std::vector<long>> xss(n);
//       // R D L U
//       const long dx[] = {1, 0, -1, 0};
//       const long dy[] = {0, 1, 0, -1};
//       for(long y = 0; y < n; ++y) {
//          for(long x = 0; x < m; ++x) {
//             long count = 0;
//             for(long i = 0; i < 4; ++i) {
//                long nx = x + dx[i];
//                long ny = y + dy[i];
//                if( not ( 0 <= nx and nx < m and 0 <= ny and ny < n ) ) continue;
//                if( field[y][x] == '1' and field[ny][nx] == '0' ) count += 1;
//             }
//             xss[y].push_back(count == 1 ? 1 : 0);
//          }
//       }
//       S022<long> leafCount(xss);
//       std::vector<std::vector<long>> cut[4];
//       for(long i = 0; i < 4; ++i) {
//          cut[i].resize(n);
//          for(long y = 0; y < n; ++y) {
//             for(long x = 0; x < m; ++x) {
//                long count = 0;
//                long nx = x + dx[i];
//                long ny = y + dy[i];
//                if( 0 <= nx and nx < m and 0 <= ny and ny < n ) {
//                   if( field[y][x] == '1' and field[ny][nx] == '1' ) count = 1;
//                }
//                cut[i][y].push_back(count == 1 ? 1 : 0);
//             }
//          }
//       }
//       S022<long> cutR(cut[0]), cutD(cut[1]), cutL(cut[2]), cutU(cut[3]);
//       for(long i = 0; i < q; ++i) {
//          long x1, y1, x2, y2;
//          scan(y1, x1, y2, x2);
//          dumpll(x1, y1);
//          dumpll(x2, y2);
//          long leafs = leafCount.f(x1 - 1, y1 - 1, x2, y2);
//          long cuts =
//             cutR.f(x2 - 1, y1 - 1, x2, y2) +
//             cutD.f(x1 - 1, y2 - 1, x2, y2) +
//             cutL.f(x1 - 1, y1 - 1, x1, y2) +
//             cutU.f(x1 - 1, y1 - 1, x2, y1);
//          dumpll(leafs, cuts);
//          printf("%ld\n", (leafs + cuts) / 2);
//       }
//    }
// };



Measured memory_bytes: 196224