#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int x1,y1,x2,y2;
};

int table[10005];
Info info[10000];

int N,command;
int min_x,min_y,max_x,max_y;

int calc_S(){

	int ret = 0;

	for(int x = min_x; x <= max_x; x++){
		for(int y = min_y-1; y <= max_y+1; y++)table[y] = 0;

		for(int i = 0; i < N; i++){
			if(info[i].x1 <= x && info[i].x2 > x){
				table[info[i].y1]++;
				table[info[i].y2]--;
			}
		}

		for(int y = min_y; y <= max_y+1; y++){
			table[y] += table[y-1];
			if(table[y] > 0)ret++;
		}
	}
	return ret;
}

int calc_L(){

	int ret = 0;

	//水平な線
	for(int x = min_x; x <= max_x; x++){
		for(int y = min_y-1; y <= max_y+1; y++)table[y] = 0;

		for(int i = 0; i < N; i++){
			if(info[i].x1 <= x && info[i].x2 > x){
				table[info[i].y1]++;
				table[info[i].y2]--;
			}
		}

		for(int y = min_y; y <= max_y+1; y++){
			table[y] += table[y-1];
			if(table[y] > 0 && table[y-1] == 0)ret++;
			if(table[y] == 0 && table[y-1] > 0)ret++;
		}
	}

	//垂直な線
	for(int y = min_y; y <= max_y; y++){
		for(int x = min_x-1; x <= max_x+1; x++)table[x] = 0;

		for(int i = 0; i < N; i++){
			if(info[i].y1 <= y && info[i].y2 > y){
				table[info[i].x1]++;
				table[info[i].x2]--;
			}
		}

		for(int x = min_y; x <= max_x+1; x++){
			table[x] += table[x-1];
			if(table[x] > 0 && table[x-1] == 0)ret++;
			if(table[x] == 0 && table[x-1] > 0)ret++;
		}
	}

	return ret;
}

void func(){

	min_x = BIG_NUM;
	min_y = BIG_NUM;
	max_x = -BIG_NUM;
	max_y = -BIG_NUM;

	for(int i = 0; i < N; i++){

		scanf("%d %d %d %d",&info[i].x1,&info[i].y1,&info[i].x2,&info[i].y2);
		info[i].x1++;
		info[i].y1++;
		info[i].x2++;
		info[i].y2++;

		min_x = min(min_x,min(info[i].x1,info[i].x2));
		min_y = min(min_y,min(info[i].y1,info[i].y2));

		max_x = max(max_x,max(info[i].x1,info[i].x2));
		max_y = max(max_y,max(info[i].y1,info[i].y2));
	}

	printf("%d\n",calc_S());

	if(command == 2){
		printf("%d\n",calc_L());
	}
}

int main(){

	while(true){
		scanf("%d %d",&N,&command);
		if(N == 0 && command == 0)break;

		func();
	}

	return 0;
}

