Problem: There is a square grid of size n × n. Some cells are colored in black, all others are colored in white. In one operation you can select some rectangle and color all its cells in white. It costs min(h, w) to color a rectangle of size h × w. You are to make all cells white for minimum total cost.

The square is large, so we give it to you in a compressed way. The set of black cells is the union of m rectangles.

Input

The first line contains two integers n and m (1 ≤ n ≤ 10^{9}, 0 ≤ m ≤ 50) — the size of the square grid and the number of black rectangles.

Each of the next m lines contains 4 integers x_{i1} y_{i1} x_{i2} y_{i2} (1 ≤ x_{i1} ≤ x_{i2} ≤ n, 1 ≤ y_{i1} ≤ y_{i2} ≤ n) — the coordinates of the bottom-left and the top-right corner cells of the i-th black rectangle.

The rectangles may intersect.

Output

Print a single integer — the minimum total cost of painting the whole square in white.

Examples

Input


10 2
4 1 5 10
1 4 10 5


Output


4


Input


7 6
2 1 2 1
4 2 4 3
2 5 2 5
2 3 5 3
1 2 1 2
3 2 5 3


Output


3

Note

The examples and some of optimal solutions are shown on the pictures below.

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MN = 222;
const int MM = 105;
long long res[MN][MN];
long long s, t, f, mf;
const long long INF = 1e12;
long long p[MN];
vector<int> g[MN];
void aug(int u, long long fl) {
  if (u == s) {
    f = fl;
    return;
  }
  aug(p[u], min(res[p[u]][u], fl));
  res[p[u]][u] -= f;
  res[u][p[u]] += f;
}
pair<long long, long long> st[MN], ed[MN];
set<long long> rv, cv;
map<long long, long long> rl, cl, rr, cr;
int main() {
  s = MN - 2;
  t = MN - 1;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    st[i] = {a, b};
    ed[i] = {c, d};
    rv.insert(a);
    rv.insert(c);
    cv.insert(b);
    cv.insert(d);
  }
  int rid = 0;
  for (auto& it : rv) {
    rr[rid] = it;
    rl[it] = rid++;
  }
  rid = 0;
  for (auto& it : cv) {
    cr[rid] = it;
    cl[it] = rid++;
  }
  memset(res, 0, sizeof(res));
  for (int i = 0; i < m; i++) {
    int a = rl[st[i].first];
    int b = cl[st[i].second];
    int c = rl[ed[i].first];
    int d = cl[ed[i].second];
    for (int j = a; j < c; j++) {
      for (int k = b; k < d; k++) {
        if (res[j][k + MM] <= 0) {
          res[j][k + MM] = INF;
          g[j].push_back(k + MM);
          g[k + MM].push_back(j);
        }
      }
    }
  }
  long long rs = n;
  int id = rv.size() - 1;
  for (auto it = rv.rbegin(); it != rv.rend(); it++) {
    res[s][id] = rs - *it;
    g[s].push_back(id);
    g[id].push_back(s);
    rs = *it;
    id--;
  }
  rs = n;
  id = cv.size() - 1;
  for (auto it = cv.rbegin(); it != cv.rend(); it++) {
    res[id + MM][t] = rs - *it;
    g[t].push_back(id + MM);
    g[id + MM].push_back(t);
    rs = *it;
    id--;
  }
  while (1) {
    queue<int> q;
    bitset<MN> vs;
    q.push(s);
    vs.set(s);
    f = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i];
        if (res[u][v] <= 0) continue;
        if (vs[v]) continue;
        vs.set(v);
        q.push(v);
        p[v] = u;
      }
      if (vs[t]) break;
    }
    if (!vs[t]) break;
    aug(t, INF);
    if (f == 0) break;
    mf += f;
  }
  cout << mf << '\n';
}