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>
using namespace std;

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

template <i64 p>
class fp {
    public:
    i64 x;
    fp() : x(0) {}
    fp(i64 x_) : x((x_ % p + p) % p) {}
    fp operator+() const { return fp(x); }
    fp operator-() const { return fp(-x); }
    fp& operator+=(const fp& y) {
        x += y.x;
        if (x >= p) x -= p;
        return *this;
    }
    fp& operator-=(const fp& y) { return *this += -y; }
    fp& operator*=(const fp& y) {
        x = x * y.x % p;
        return *this;
    }
    fp& operator/=(const fp& y) { return *this *= fp(inverse(y.x)); }
    fp operator+(const fp& y) const { return fp(x) += y; }
    fp operator-(const fp& y) const { return fp(x) -= y; }
    fp operator*(const fp& y) const { return fp(x) *= y; }
    fp operator/(const fp& y) const { return fp(x) /= y; }
    bool operator==(const fp& y) const { return x == y.x; }
    bool operator!=(const fp& y) const { return !(*this == y); }
    i64 extgcd(i64 a, i64 b, i64& x, i64& y) {
        i64 d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    i64 inverse(i64 a) {
        i64 x, y;
        extgcd(a, p, x, y);
        return (x % p + p) % p;
    }
};

template <i64 p>
i64 abs(const fp<p>& x) { return x.x; }

template <i64 p>
istream& operator>>(istream& is, fp<p>& x) {
    is >> x.x;
    return is;
}

template <i64 p>
ostream& operator<<(ostream& os, const fp<p>& x) {
    os << x.x;
    return os;
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "[";
    for (const auto& v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T& val) {
    fill((T*)ary, (T*)(ary + size), val);
}

// x未満の要素の個数を返す
template <typename T>
i64 count_less(const vector<T>& v, T x) {
    return lower_bound(begin(v), end(v), x) - begin(v);
}

// x以下の要素の個数を返す
template <typename T>
i64 count_less_or_equal(const vector<T>& v, T x) {
    return upper_bound(begin(v), end(v), x) - begin(v);
}

// xより大きい要素の個数を返す
template <typename T>
i64 count_greater(const vector<T>& v, T x) {
    return end(v) - upper_bound(begin(v), end(v), x);
}

// x以上の要素の個数を返す
template <typename T>
i64 count_greater_or_equal(const vector<T>& v, T x) {
    return end(v) - lower_bound(begin(v), end(v), x);
}

// x未満の要素のうち最大のものを返す
template <typename T>
T max_less(const vector<T>& v, T x) {
    return *(lower_bound(begin(v), end(v), x) - 1);
}

// x以下の要素のうち最大のものを返す
template <typename T>
T max_less_or_equal(const vector<T>& v, T x) {
    return *(upper_bound(begin(v), end(v), x) - 1);
}

// xより大きい要素のうち最小のものを返す
template <typename T>
T min_greater(const vector<T>& v, T x) {
    return *upper_bound(begin(v), end(v), x);
}

// x以上の要素のうち最小のものを返す
template <typename T>
T min_greater_or_equal(const vector<T>& v, T x) {
    return *lower_bound(begin(v), end(v), x);
}

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr long double eps = 1e-9;

// 実数値のn分探索のループ回数の上限(2分探索なら50でも十分かもしれない)
constexpr i64 max_loop = 100;

/*
 *  計算量: 初期化 O(NlogN), 展開 O(1), 圧縮 O(logN)
 *  (unzip, zip)のペアを返す.
 *  unzipは圧縮後の座標を受け取り, 圧縮後の座標を返す.
 *  zipは圧縮後の座標を受け取り, 圧縮前の座標を返す.
 */
template<typename T> pair<vector<T>, map<T, T>> compress(const vector<T>& xs){
    vector<T> unzip;
    unzip.reserve(xs.size());
    for(const auto& x:xs) unzip.emplace_back(x);

    sort(begin(unzip),end(unzip));
    unzip.erase(unique(begin(unzip),end(unzip)),end(unzip));

    map<T, i64> zip;
    rep(i,0,unzip.size()) zip[unzip[i]]=i;

    return make_pair(unzip,zip);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;

    vector<i64> x1(N),y1(N),x2(N),y2(N);
    rep(i,0,N) {
        cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
        --x2[i];
        --y2[i];
    }
    
    vector<i64> xs;
    rep(i,0,N){
        xs.emplace_back(x1[i]);
        xs.emplace_back(x2[i]);
        xs.emplace_back(x2[i]+1);
    }

    vector<i64> ys;
    rep(i,0,N){
        ys.emplace_back(y1[i]);
        ys.emplace_back(y2[i]);
        ys.emplace_back(y2[i]+1);
    }

    vector<i64> unzip_x,unzip_y;
    map<i64,i64> zip_x,zip_y;
    tie(unzip_x,zip_x)=compress(xs);
    tie(unzip_y,zip_y)=compress(ys);

    const i64 w=zip_x.size(),h=zip_y.size();
    vector<vector<int16_t>> cnt(w,vector<int16_t>(h));
    rep(i,0,N){
        i64 sx=zip_x[x1[i]],sy=zip_y[y1[i]];
        i64 tx=zip_x[x2[i]],ty=zip_y[y2[i]];
        cnt[sx][sy]+=1;
        cnt[tx+1][sy]-=1;

        cnt[sx][ty+1]+=-1;
        cnt[tx+1][ty+1]+=1;
    }

    rep(y,0,h){
        rep(x,1,w){
            cnt[x][y]+=cnt[x-1][y];
        }
    }
    rep(x,0,w){
        rep(y,1,h){
            cnt[x][y]+=cnt[x][y-1];
        }
    }

    i64 ans=0;
    rep(x,0,w-1){
        rep(y,0,h-1){
            if(cnt[x][y]>=1){
                i64 width=unzip_x[x+1]-unzip_x[x];
                i64 height=unzip_y[y+1]-unzip_y[y];
                ans+=width*height;
            }
        }
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

