import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int n, r;
    while (readf("%d %d\n", &n, &r), n || r) {
        int[][] F = new int[][n];
        int X, Y;
        foreach (i; 0 .. n) {
            int x1, y1, x2, y2;
            readf("%d %d %d %d\n", &x1, &y1, &x2, &y2);
            F[i] = [x1, y1, x2, y2];
            X = max(X, x2);
            Y = max(Y, y2);
        }
        int area = 0;
        int[] d = new int[10001];
        foreach (i; 0 .. Y + 1) {
            foreach (j; 0 .. n) {
                if (F[j][1] <= i && i < F[j][3]) {
                    d[F[j][0]]++;
                    d[F[j][2]]--;
                }
            }
            int c = 0;
            foreach (j; 0 .. X + 1) {
                if (d[j] != 0) {
                    c += d[j];
                    d[j] = 0;
                }
                if (c) area++;
            }
        }
        area.writeln;
        if (r == 2) {
            int cir = 0;
            int c = 0;
            foreach (i; 0 .. Y + 1) {
                foreach (j; 0 .. n) {
                    if (F[j][1] <= i && i < F[j][3]) {
                        d[F[j][0]]++;
                        d[F[j][2]]--;
                    }
                }
                foreach (j; 0 .. X + 1) {
                    if (d[j] != 0) {
                        if (c == 0) cir++;
                        c += d[j];
                        d[j] = 0;
                        if (c == 0) cir++;
                    }
                }
            }
            foreach (i; 0 .. X + 1) {
                foreach (j; 0 .. n) {
                    if (F[j][0] <= i && i < F[j][2]) {
                        d[F[j][1]]++;
                        d[F[j][3]]--;
                    }
                }
                foreach (j; 0 .. Y + 1) {
                    if (d[j] != 0) {
                        if (c == 0) cir++;
                        c += d[j];
                        d[j] = 0;
                        if (c == 0) cir++;
                    }
                }
            }
            cir.writeln;
        }
    }
}