#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int n, r;
pair<pint,pint> inp[2][10100]; // x座標の範囲, y座標の範囲
pair<pint,pint> inp2[10100]; // y座標の範囲, x座標の範囲

int pre[2][10100], ri[2][10100];
int syui[2][10100];
int area[2][10100];

int main() {
    while (cin >> n >> r) {
        if (n == 0) break;
        for (int i = 0; i < n; ++i) {
            cin >> inp[0][i].first.first >> inp[0][i].second.first >> inp[0][i].first.second >> inp[0][i].second.second;
            inp[1][i].first.first = inp[0][i].second.first;
            inp[1][i].first.second = inp[0][i].second.second;
            inp[1][i].second.first = inp[0][i].first.first;
            inp[1][i].second.second = inp[0][i].first.second;
        }
        sort(inp[0], inp[0]+n); sort(inp[1], inp[1]+n);
        
        memset(pre, -1, sizeof(pre));
        memset(ri, -1, sizeof(ri));
        memset(syui, 0, sizeof(syui));
        memset(area, 0, sizeof(area));
        
        for (int it = 0; it < 2; ++it) {
            for (int i = 0; i < n; ++i) {
                int xl = inp[it][i].first.first, xr = inp[it][i].first.second;
                for (int y = inp[it][i].second.first; y < inp[it][i].second.second; ++y) {
                    if (ri[it][y] < xl) {
                        syui[it][y] += 2;
                        area[it][y] += xr - xl;
                    }
                    else {
                        if (xr > ri[it][y])
                            area[it][y] += xr - ri[it][y];
                    }
                
                    pre[it][y] = xl;
                    ri[it][y] = max(ri[it][y], xr);
                }
            }
        }
        
        int tot_area = 0, tot_syui = 0;
        for (int i = 0; i <= 10000; ++i) {
            tot_area += area[0][i];
            tot_syui += syui[0][i] + syui[1][i];
        }
        
        if (r == 1) cout << tot_area << endl;
        if (r == 2) cout << tot_area << endl << tot_syui << endl;
    }
    return 0;
}


Measured memory_bytes: 1960