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<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2) {
    vector<T> vals;
    long long K = (long long)C1.size();
    for (long long i = 0; i < K; i++) {
        for (T d = 0; d < 1; d++) {  // その位置と、一つ隣を確保(隣を確保しないと空白が埋まってしまうことがある)
            T tc1 = C1[i] + d;
            T tc2 = C2[i] + d;
            vals.push_back(tc1);
            vals.push_back(tc2);
        }
    }
    // ソート
    sort(vals.begin(), vals.end());
    // 隣り合う重複を削除(unique), 末端のゴミを削除(erase)
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    for (long long i = 0; i < K; i++) {
        C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
        C2[i] = lower_bound(vals.begin(), vals.end(), C2[i]) - vals.begin();
    }
    return vals;
}

long long a[4000][4000] = {0};

int main() {
  long long N;
  cin >> N;
  vector<long long> x1, x2;
  vector<long long> y1, y2;
  rep(i, N) {
    long long p, q, r, s;
    cin >> p >> q >> r >> s;
    x1.push_back(p);
    y1.push_back(q);
    x2.push_back(r);
    y2.push_back(s);
  }
  vector<long long> x;
  vector<long long> y;
  x = compress(x1, x2);
  y = compress(y1, y2);

  // rep(i, N) {
  //   for(long long p = x1[i]; p < x2[i]; p++) {
  //     for(long long q = y1[i]; q < y2[i]; q++) {
  //       a[p][q] += 1;
  //     }
  //   }
  // }
  rep(i, N) {
    a[x1[i]][y1[i]] += 1;
    a[x1[i]][y2[i]] += -1;
    a[x2[i]][y1[i]] += -1;
    a[x2[i]][y2[i]] += 1;  
  }
  long long ans = 0;
  rep(i, x.size()) {
    rep(j, y.size()-1) {
      a[i][j+1] += a[i][j];
    }
  }
  rep(i, x.size()-1) {
    rep(j, y.size()) {
      a[i+1][j] += a[i][j];
    }
  }
  rep(i, x.size()-1) {
    rep(j, y.size()-1) {
      if(a[i][j] > 0) {
        ans += (x[i+1]-x[i]) * (y[j+1]-y[j]);
      }
      // cout << a[i][j] << " ";
    }
    // cout << endl;
  }
  
  cout << ans << endl;
  // rep(i, x1.size()) {
  //   cout << x1[i] << " "; 
  // }
  // cout << endl;
  // rep(i, y1.size()) {
  //   cout << y1[i] << " "; 
  // }
  // cout << endl;
  // rep(i, x2.size()) {
  //   cout << x2[i] << " "; 
  // }
  // cout << endl;
  // rep(i, y2.size()) {
  //   cout << y2[i] << " "; 
  // }
  // cout << endl;
  return 0;
}
