#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> adj[n + 1];
  int mx = 0;
  for (int i = 0; i < m; ++i) {
    int start, end;
    cin >> start >> end;
    adj[start].push_back(end);
  }
  for (int i = 1; i <= n; ++i) {
    sort(adj[i].begin(), adj[i].end());
  }
  vector<int> short_dis(n + 1);
  for (int x = 1; x <= n; ++x) {
    auto it = lower_bound(adj[x].begin(), adj[x].end(), x);
    if (it != adj[x].end()) {
      short_dis[x] = (*it) - x;
      if (short_dis[x] < 0) short_dis[x] += n;
    } else {
      it = lower_bound(adj[x].begin(), adj[x].end(), 1);
      if (it != adj[x].end()) {
        short_dis[x] = (*it) - x;
        if (short_dis[x] < 0) short_dis[x] += n;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (short_dis[j] == 0) continue;
      int dis = j - i;
      if (dis < 0) dis += n;
      ans = max(ans, ((int)adj[j].size() - 1) * n + short_dis[j] + dis);
    }
    cout << ans << " ";
  }
  return 0;
}
