#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
vector<int> _vec[5003];
vector<int> drop[5003], vec[5003];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a >= b) b += n;
    _vec[a].push_back(b);
  }
  int rounds = 0;
  for (int i = 0; i < 5003; i++) {
    sort(_vec[i].begin(), _vec[i].end());
    rounds = max(rounds, (int)_vec[i].size());
  }
  rounds--;
  for (int k = 0; k < n; k++) {
    int total = 0;
    for (int i = 0; i < 5003; i++) {
      if (rounds + 1 == (int)_vec[i].size()) {
        vec[i].push_back(_vec[i][0]);
        total++;
      }
    }
    for (int i = 0; i < 5003; i++) {
      if (rounds == 0) continue;
      if ((int)_vec[i].size() < rounds) continue;
      int j = (int)_vec[i].size() - rounds;
      cerr << "AQUI " << j << " " << rounds << endl;
      int x = _vec[i][j];
      if ((i < k && x > k) || (x > k + n)) {
        if (x >= n) {
          x -= n;
        }
        drop[x].push_back(i);
        total++;
      }
    }
    int cnt = n * rounds;
    int last = cnt;
    while (total) {
      for (int x = 0; x < n; x++) {
        int i = (x + k) % n;
        while (!drop[i].empty()) {
          total--;
          drop[i].pop_back();
          last = cnt;
        }
        if ((int)vec[i].size()) {
          int w = vec[i][(int)vec[i].size() - 1];
          if (w >= n) w -= n;
          drop[w].push_back(i);
          vec[i].pop_back();
        }
        cnt++;
      }
    }
    cout << last << " ";
  }
  cout << endl;
}
