#include <bits/stdc++.h>
using namespace std;
int n, m;
int cnt[200005];
int minElem[200005];
int main() {
  memset(minElem, 31, sizeof(minElem));
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    cnt[a]++;
    minElem[a] = min(minElem[a], (b + n - a) % n);
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    for (int j = 1; j <= n; j++) {
      long long temp = 0;
      if (cnt[j]) {
        temp = (cnt[j] - 1) * 1LL * n + minElem[j] + (j + n - i) % n;
      }
      ans = max(temp, ans);
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
