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 ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "CONTINUE"
#define FALSE__ "GAMEOVER"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define fcout cout << fixed << setprecision(12)

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

vector<int> Xc;
vector<int> Yc;
vector<int> X;
vector<int> Y;
int N;


void init()
{
	cin >> N;
	vector<int> xo, yo;
	map<int, int> mx, my;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		xo.PB(x);
		yo.PB(y);
		mx[x] = 1;
		my[y] = 1;
		cin >> x >> y;
		xo.PB(x);
		yo.PB(y);
		mx[x] = 1;
		my[y] = 1;
	}
	int cnt = 0;
	for (auto& a : mx) {
		a.second = cnt++;
		Xc.PB(a.first);
	}
	cnt = 0;
	for (auto& a : my) {
		a.second = cnt++;
		Yc.PB(a.first);
	}
	rep(i, N) {
		int j = i * 2;
		X.PB(mx[xo[j]]);
		Y.PB(my[yo[j]]);
		X.PB(mx[xo[j+1]]);
		Y.PB(my[yo[j+1]]);
	}

}

void solve()
{
	ll res = 0;
	vector<vector<int>> imos(N*2+2, vector<int>(N*2+2, 0));
	rep(i, N) {
		int j = i * 2;
		imos[X[j]][Y[j]]++;
		imos[X[j+1]][Y[j+1]]++;
		imos[X[j]][Y[j+1]]--;
		imos[X[j+1]][Y[j]]--;
	}
	rep(i, N*2+2) {
		reps(j, 1, N*2+2) {
			imos[i][j] += imos[i][j-1];
		}
	}
	rep(j, N*2+2) {
		reps(i, 1, N*2+2) {
			imos[i][j] += imos[i-1][j];
		}
	}
	rep(j, N*2+2) {
		rep(i, N*2+2) {
			if (imos[i][j]) {
				res += (ll) (Xc[i+1] - Xc[i]) * (Yc[j+1] - Yc[j]);
			}
		}
	}
	cout << res << endl;
}




