#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const int maxn = 110000;
multiset<int> e[maxn];
int n, m;
int col[maxn];
vector<int> te[maxn];
void add_diag(int a, int b) {
  e[a].insert((b - a + n) % n);
  e[b].insert((a - b + n) % n);
}
int dfs(int v, int p = -1) {
  int m1 = 0, m2 = 0;
  for (int u : te[v]) {
    if (u == p) continue;
    int m = dfs(u, v);
    m2 |= m & m1;
    m1 |= m;
  }
  int res = 0;
  while (((m1 >> res) & 1) || (m2 >> res)) ++res;
  col[v] = res;
  return (m1 | (1 << res)) & ~((1 << res) - 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> n >> m;
  for (int i = 0; i < (int)(n); ++i) add_diag(i, (i + 1) % n);
  for (int i = 0; i < (int)(m); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    for (int j = 0; j < (int)(2); ++j) add_diag(a, b);
  }
  vector<vector<int> > regs;
  for (int i = 0; i < (int)(n); ++i) {
    while (!e[i].empty()) {
      vector<int> reg;
      int v = i, d = *e[v].begin();
      while (1) {
        reg.push_back(v);
        int u = (v + d) % n;
        e[v].erase(e[v].find(d));
        e[u].erase(e[u].find(n - d));
        v = u;
        d = n - d;
        if (v == i) break;
        d = *(--e[u].lower_bound(d));
      }
      sort((reg).rbegin(), (reg).rend());
      regs.push_back(reg);
    }
  }
  sort((regs).begin(), (regs).end());
  map<pair<int, int>, vector<int> > edges;
  for (int j = 0; j < (int)(regs.size()); ++j) {
    auto &w = regs[j];
    for (int i = 0; i < (int)(w.size()); ++i) {
      int v = w[i], u = w[(i + 1) % w.size()];
      if (v > u) swap(v, u);
      if (u - v == 1 || u - v == n - 1) continue;
      edges[{v, u}].push_back(j);
    }
  }
  for (auto w : edges) {
    assert(w.second.size() == 2);
    te[w.second[0]].push_back(w.second[1]);
    te[w.second[1]].push_back(w.second[0]);
  }
  for (auto w : regs) {
    for (int x : w) cerr << x << ' ';
    cerr << '\n';
  }
  dfs(0);
  for (int i = 0; i < (int)(regs.size()); ++i) cout << 20 - col[i] << ' ';
  cout << '\n';
  return 0;
}
