using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ForYellow
{
    class AGC015_C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nmq = ReadInts();
            int n = nmq[0];
            int m = nmq[1];
            int q = nmq[2];
            bool[,] grid = new bool[n, m];
            for(int i = 0; i < n; i++)
            {
                string s = Read();
                for(int j = 0; j < m; j++)
                {
                    grid[i, j] = s[j] == '1';
                }
            }

            int[,] blocks = new int[n, m];
            int[,] verticals = new int[n, m];
            int[,] horizons = new int[n, m];
            for(int i = 0; i < n; i++)
            {
                blocks[i, 0] = grid[i, 0] ? 1 : 0;
                if (i > 0)
                {
                    blocks[i, 0] += blocks[i - 1, 0];
                    horizons[i, 0] = grid[i - 1, 0] && grid[i, 0] ? 1 : 0;
                    horizons[i, 0] += horizons[i - 1, 0];
                }
            }
            for (int i = 0; i < m; i++)
            {
                blocks[0,i] = grid[0,i] ? 1 : 0;
                if (i > 0)
                {
                    blocks[0, i] += blocks[0, i-1];
                    verticals[0, i] = grid[0, i - 1] && grid[0, i] ? 1 : 0;
                    verticals[0, i] += verticals[0, i - 1];
                }
            }

            for (int i = 1; i < n; i++)
            {
                for(int j = 1; j < m; j++)
                {
                    blocks[i, j] = grid[i, j] ? 1 : 0;
                    blocks[i, j] += blocks[i - 1, j] + blocks[i, j - 1];
                    blocks[i, j] -= blocks[i - 1, j - 1];

                    horizons[i,j]= grid[i - 1, j] && grid[i, j] ? 1 : 0;
                    horizons[i, j] += horizons[i - 1, j] + horizons[i, j - 1];
                    horizons[i, j] -= horizons[i - 1, j - 1];

                    verticals[i, j] = grid[i, j - 1] && grid[i, j] ? 1 : 0;
                    verticals[i, j] += verticals[i - 1, j] + verticals[i, j - 1];
                    verticals[i, j] -= verticals[i - 1, j - 1];
                }
            }

            for(int i = 0; i < q; i++)
            {
                int[] xys = ReadInts();
                int x1 = xys[0] - 1;
                int y1 = xys[1] - 1;
                int x2 = xys[2] - 1;
                int y2 = xys[3] - 1;

                int blockCnt = blocks[x2, y2];
                int verticalCnt = verticals[x2, y2] - verticals[x2, y1];
                int horizonCnt = horizons[x2, y2] - horizons[x1, y2];
                if (x1 > 0)
                {
                    blockCnt -= blocks[x1 - 1, y2];
                    verticalCnt -= verticals[x1 - 1, y2];
                    verticalCnt += verticals[x1 - 1, y1];
                }
                if (y1 > 0)
                {
                    blockCnt -= blocks[x2, y1 - 1];
                    horizonCnt -= horizons[x2, y1 - 1];
                    horizonCnt += horizons[x1, y1 - 1];
                }
                if (x1 > 0 && y1 > 0)
                {
                    blockCnt += blocks[x1 - 1, y1 - 1];
                }

                int edges = verticalCnt + horizonCnt;
                WriteLine(blockCnt - edges);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 97076