#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;
int main() {
  vector<vector<int> > adj;
  int n, m;
  cin >> n >> m;
  adj.assign(n, vector<int>());
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    b = (b - a + n) % n;
    adj[a].push_back(b);
  }
  for (int i = 0; i < n; i++) sort(adj[i].begin(), adj[i].end());
  long long ans = 0;
  vector<int> len(n, -1);
  for (int i = 0; i < n; i++) {
    if (adj[i].size()) len[i] = ((int)adj[i].size() - 1) * n + adj[i][0];
  }
  for (int i = 0; i < n; i++) {
    if (len[i] != -1) ans = max(ans, (len[i] + i) * 1LL);
  }
  for (int i = 0; i < n; i++) {
    if (i) {
      ans--;
      if (len[i - 1] != -1) ans = max(ans, 1LL * (len[i - 1] + n - 1));
    }
    cout << ans << " ";
  }
  return 0;
}
