#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  vector<int> cnt(5002), a(5002), mn(5002);
  int x, y;
  cin >> n >> m;
  for (i = 0; i <= n; i++) {
    mn[i] = 5001;
  }
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    cnt[x]++;
    mn[x] = min(mn[x], (y + n - x) % n);
  }
  for (i = 1; i <= n; i++) {
    int ans = 0;
    for (j = 1; j <= n; j++) {
      if (cnt[j]) {
        ans = max(ans, (j + n - i) % n + (cnt[j] - 1) * n + mn[j]);
      }
    }
    cout << ans << " ";
  }
  return 0;
}
