#include <bits/stdc++.h>
using namespace std;
int cnt[5005];
int nearest[5005];
int main(void) {
  int n, m;
  cin >> n >> m;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    b = b > a ? b : b + n;
    if (!cnt[a] || b < nearest[a]) nearest[a] = b;
    cnt[a]++;
  }
  for (int i = 1; i <= n; ++i) {
    int time = 0;
    for (int j = 1; j <= n; ++j) {
      int x = (cnt[j] - 1) * n + (nearest[j] + (i > j ? n : 0));
      time = max(x, time);
    }
    cout << time - i << " ";
  }
}
