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 N = 100;
tuple<int, int, int, int> r[N];
int vx[N], vy[N];
set<int> ix, iy, sx, sy;
set<int> e[N];
int fl[N][N];
bool seen[2 * N];
int dfs(int v, int f) {
  if (seen[v]) return 0;
  seen[v] = 1;
  if (v < N) {
    int x = v;
    for (int y : e[x]) {
      int fo = dfs(y + N, f);
      if (fo) {
        fl[x][y] += fo;
        return fo;
      }
    }
  } else {
    int y = v - N;
    if (vy[y]) {
      int fo = min(f, vy[y]);
      vy[y] -= fo;
      return fo;
    }
    for (int x = 0; x < N; x++)
      if (fl[x][y]) {
        int fo = min(f, fl[x][y]);
        fo = dfs(x, fo);
        if (fo) {
          fl[x][y] -= fo;
          return fo;
        }
      }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  if (!m) {
    cout << "0\n";
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int lx, hx, ly, hy;
    cin >> lx >> ly >> hx >> hy;
    r[i] = {lx, ++hx, ly, ++hy};
    ix.insert(lx);
    ix.insert(hx);
    iy.insert(ly);
    iy.insert(hy);
  }
  map<int, int> mx, my;
  {
    int i = 0;
    auto it1 = ix.begin();
    auto it2 = it1;
    it2++;
    while (it2 != ix.end()) {
      int d = *it2 - *it1;
      mx[*it1] = i;
      vx[i] = d;
      it1++;
      it2++;
      i++;
    }
    mx[*it1] = i;
    i = 0;
    it1 = iy.begin();
    it2 = it1;
    it2++;
    while (it2 != iy.end()) {
      int d = *it2 - *it1;
      my[*it1] = i;
      vy[i] = d;
      it1++;
      it2++;
      i++;
    }
    my[*it1] = i;
  }
  for (int i = 0; i < m; i++) {
    int lx, hx, ly, hy;
    tie(lx, hx, ly, hy) = r[i];
    lx = mx[lx];
    hx = mx[hx];
    ly = my[ly];
    hy = my[hy];
    for (int x = lx; x < hx; x++)
      for (int y = ly; y < hy; y++) e[x].insert(y);
  }
  int mf = 0;
  int lx = 0;
  for (int x = 0; x < N; x++)
    for (int f = 1; f && vx[x];) {
      fill(seen, seen + 2 * N, 0);
      f = dfs(x, vx[x]);
      vx[x] -= f;
      mf += f;
    }
  cout << mf << '\n';
}