#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pii> v(m);
  for (int i = 0; i < m; i++) {
    cin >> v[i].first >> v[i].second;
    if (v[i].first > v[i].second) v[i].second += n;
  }
  sort(v.begin(), v.end(), [](const pii &p1, const pii &p2) -> bool {
    return (p1.first == p2.first) ? p1.second > p2.second : p1.first < p2.first;
  });
  for (int start = 1; start <= n; start++) {
    int i = 0;
    int finish = 0;
    while (i < m) {
      int tmp = v[i].first;
      int cnt = 0;
      if (tmp < start) cnt = 1;
      while (i < m && v[i].first == tmp) {
        finish = max(finish, v[i].second + n * cnt);
        cnt += 1;
        i += 1;
      }
    }
    cout << finish - start << " ";
  }
  return 0;
}
