Given a set of $N$ axis-aligned rectangles in the plane, find the area of regions which are covered by at least one rectangle.

Constraints

* $ 1 \leq N \leq 2000 $
* $ −10^9 \leq x1_i < x2_i\leq 10^9 $
* $ −10^9 \leq y1_i < y2_i\leq 10^9 $

Input

The input is given in the following format.

$N$
$x1_1$ $y1_1$ $x2_1$ $y2_1$
$x1_2$ $y1_2$ $x2_2$ $y2_2$
:
$x1_N$ $y1_N$ $x2_N$ $y2_N$


($x1_i, y1_i$) and ($x2_i, y2_i$) are the coordinates of the top-left corner and the bottom-right corner of the $i$-th rectangle respectively.

Output

Print the area of the regions.

Examples

Input

2
0 0 3 4
1 2 4 3


Output

13


Input

3
1 1 2 5
2 1 5 2
1 2 2 5


Output

7


Input

4
0 0 3 1
0 0 1 3
0 2 3 3
2 0 3 3


Output

8
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

class Conv {
    ll cursor = 0;
    map<ll, ll> to_short; // <original, small >
    map<ll, ll> to_long; // <small, original>


public:
    void set(ll original) {
        if (to_short.find(original) != to_short.end()) {
            return;
        }
        to_long[cursor] = original;
        to_short[original] = cursor;
        cursor++;
    }

    ll revert(ll after) {
        assert(to_long.find(after) != to_long.end());
        return to_long[after];
    }

    ll convert(ll original) {
        assert(to_short.find(original) != to_short.end());
        return to_short[original];
    }

    ll next() {
        return cursor;
    }

};

class MatrixSum {
    vector<vector<ll>> sum;
public:
    MatrixSum(ll x, ll y) {
        sum = vector<vector<ll>>(x, vector<ll>(y));
    }

    void add(ll x, ll y) {
        sum[x][y]++;
    }

    void sub(ll x, ll y) {
        sum[x][y]--;
    }


    ll get(ll x, ll y) {
        if (x == -1 || y == -1) {
            return 0;
        }
        if (x == sum.size() || y == sum[x].size()) {
            return 0;
        }
        return sum[x][y];
    }

    void setUp() {
        for (ll x = 0; x < sum.size(); x++) {
            for (ll y = 0; y < sum[x].size(); y++) {
                sum[x][y] += get(x - 1, y) + get(x, y - 1) - get(x - 1, y - 1);
            }
        }
    }

    ll getSum(ll xs, ll ys, ll xe, ll ye) {
        return get(xe, ye) - get(xs - 1, ye) - get(xe, ys - 1) + get(xs - 1, ys - 1);
    }

    void print() {
        rep(y, sum.size()) {
            print_line(sum[y]);
        }
    }

};

struct Rectangle {
    ll lx, uy, rx, dy;
};

int main() {

    int n;
    cin >> n;

    vector<Rectangle> original_rectangles(n);

    Conv convx, convy;
    convx.set(-INF);
    convy.set(-INF);

    rep(i, n) {
        ll lx, uy, rx, dy;
        cin >> lx >> uy >> rx >> dy;
        original_rectangles[i].lx = lx;
        original_rectangles[i].uy = uy;
        original_rectangles[i].rx = rx;
        original_rectangles[i].dy = dy;
    }

    {
        // x
        vector<ll> points;
        for (Rectangle &r : original_rectangles) {
            points.push_back(r.lx);
            points.push_back(r.rx);
        }
        sort(points.begin(), points.end());
        for (ll l : points)convx.set(l);
    }

    {
        // y
        vector<ll> points;
        for (Rectangle &r : original_rectangles) {
            points.push_back(r.uy);
            points.push_back(r.dy);
        }
        sort(points.begin(), points.end());
        for (ll l : points)convy.set(l);
    }

    convx.set(INF);
    convy.set(INF);

    vector<Rectangle> compress_rectangles(n);
    rep(i, n) {
        compress_rectangles[i].lx = convx.convert(original_rectangles[i].lx);
        compress_rectangles[i].rx = convx.convert(original_rectangles[i].rx);
        compress_rectangles[i].uy = convy.convert(original_rectangles[i].uy);
        compress_rectangles[i].dy = convy.convert(original_rectangles[i].dy);
    }

    MatrixSum ms(convx.next(), convy.next());
    for (Rectangle &r : compress_rectangles) {
        ms.add(r.lx, r.uy);
        ms.sub(r.lx, r.dy);
        ms.sub(r.rx, r.uy);
        ms.add(r.rx, r.dy);
    }
    ms.setUp();

//    ms.print();

    ll sum = 0;

    for (ll x = 0; x < convx.next() - 1; x++) {
        for (ll y = 0; y < convy.next() - 1; y++) {
            if (ms.get(x, y) > 0) {
                ll lx = convx.revert(x);
                ll rx = convx.revert(x + 1);
                ll uy = convy.revert(y);
                ll dy = convy.revert(y + 1);

                ll height = abs(uy - dy);
                ll width = abs(rx - lx);
                ll rect = height * width;
                sum += rect;
            }
        }
    }
    cout << sum << endl;


}

