#include <bits/stdc++.h>
using namespace std;
int a[20000 + 10], b[20000 + 10], out[10000 + 10], mi[10000 + 10];
queue<int> q[100 + 10];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) mi[i] = n;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    out[a[i]]++;
    mi[a[i]] = min(mi[a[i]], (b[i] - a[i] + n) % n);
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (out[j] > 0) {
        ans = max(ans, (out[j] - 1) * n + mi[j] + (j + n - i) % n);
      }
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
