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>

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  using T = tuple<int, int, int, int>;
  using P = pair<int, int>;
  vector<T> data;
  set<int> xset, yset;
  rep(i, n) {
    vi32 x(2), y(2);
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    data.emplace_back(x[0], y[0], x[1], y[1]);
    rep(j, 2) xset.insert(x[j]);
    rep(j, 2) yset.insert(y[j]);
  }
  vi32 xs, ys;
  each(x, xset) xs.push_back(x);
  each(y, yset) ys.push_back(y);
  int xn = sz(xs);
  int yn = sz(ys);
  vector<vi32> sums(xn, vi32(yn));
  auto xindex = [&](int x) -> int {
    return lower_bound(all(xs), x) - xs.begin();
  };
  auto yindex = [&](int y) -> int {
    return lower_bound(all(ys), y) - ys.begin();
  };
  rep(i, n) {
    vi32 x(2), y(2);
    tie(x[0], y[0], x[1], y[1]) = data[i];
    vi32 xi(2), yi(2);
    rep(j, 2) xi[j] = xindex(x[j]);
    rep(j, 2) yi[j] = yindex(y[j]);
    sums[xi[0]][yi[0]] += 1;
    sums[xi[0]][yi[1]] -= 1;
    sums[xi[1]][yi[0]] -= 1;
    sums[xi[1]][yi[1]] += 1;
  }
  rep(i, xn) rep(j, yn - 1) {
    sums[i][j + 1] += sums[i][j];
  }
  rep(j, yn) rep(i, xn - 1) {
    sums[i + 1][j] += sums[i][j];
  }
  i64 ans = 0;
  rep(i, xn - 1) rep(j, yn - 1) {
    if (sums[i][j] == 0) continue;
    vi32 x(2), y(2);
    x[0] = xs[i], x[1] = xs[i + 1];
    y[0] = ys[j], y[1] = ys[j + 1];
    ans += (i64) (x[1] - x[0]) * (y[1] - y[0]);
  }
  cout << ans << endl;
}

