using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5 5 2");
WillReturn.Add("1 1 3 3");
WillReturn.Add("2 2 4 4");
//1 1 1 0 0
//1 2 2 1 0
//1 2 2 1 0
//0 1 1 1 0
//0 0 0 0 0
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int[] wkArr = { };
Action<string> SplitAct = pStr =>
wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray();
SplitAct(InputList[0]);
int UB_X = wkArr[1];
int UB_Y = wkArr[0];
int[,] ImosArr = new int[UB_X + 1, UB_Y + 1];
foreach (string EachStr in InputList.Skip(1)) {
SplitAct(EachStr);
int A = wkArr[0];
int B = wkArr[1];
int C = wkArr[2];
int D = wkArr[3];
int StaX = B;
int StaY = A;
int EndX = D + 1;
int EndY = C + 1;
ImosArr[StaX, StaY]++;
if (EndX <= UB_X) ImosArr[EndX, StaY]--;
if (EndY <= UB_Y) ImosArr[StaX, EndY]--;
if (EndX <= UB_X && EndY <= UB_Y) ImosArr[EndX, EndY]++;
}
//横方向の累積和を求める
for (int X = 1; X <= UB_X; X++) {
for (int Y = 0; Y <= UB_Y; Y++) {
ImosArr[X, Y] += ImosArr[X - 1, Y];
}
}
//縦方向の累積和を求める
for (int Y = 1; Y <= UB_Y; Y++) {
for (int X = 0; X <= UB_X; X++) {
ImosArr[X, Y] += ImosArr[X, Y - 1];
}
}
for (int Y = 1; Y <= UB_Y; Y++) {
var AnswerList = new List<int>();
for (int X = 1; X <= UB_X; X++) {
AnswerList.Add(ImosArr[X, Y]);
}
Console.WriteLine(IntEnumJoin(" ", AnswerList));
}
}
////////////////////////////////////////////////////////////////
// 2次元配列(int型)のデバッグ出力
////////////////////////////////////////////////////////////////
static void PrintBan(int[,] pBanArr)
{
var sb = new System.Text.StringBuilder();
for (int Y = 0; Y <= pBanArr.GetUpperBound(1); Y++) {
for (int X = 0; X <= pBanArr.GetUpperBound(0); X++) {
sb.Append(pBanArr[X, Y]);
}
sb.AppendLine();
}
Console.Write(sb.ToString());
}
// セパレータとInt型の列挙を引数として、結合したstringを返す
static string IntEnumJoin(string pSeparater, IEnumerable<int> pEnum)
{
string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString());
return string.Join(pSeparater, StrArr);
}
}