#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, A, B, tmp, terbanyak = 0;
  cin >> N >> M;
  int permen[N + 1], cnt[N + 1];
  for (int i = 0; i <= N; i++) {
    permen[i] = N;
    cnt[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> A >> B;
    cnt[A]++;
    tmp = B - A;
    if (tmp < 0) tmp += N;
    permen[A] = min(permen[A], tmp);
    terbanyak = max(terbanyak, cnt[A]);
  }
  for (int i = 1; i <= N; i++) {
    if (i > 1) cout << ' ';
    int terjauh = 0;
    for (int j = 0; j < N; j++) {
      tmp = (i + j) % N;
      if (tmp <= 0) tmp += N;
      if (cnt[tmp] <= 0) continue;
      if (terbanyak == cnt[tmp]) {
        terjauh = max(terjauh, j + permen[tmp]);
      } else if (terbanyak == cnt[tmp] + 1) {
        terjauh = max(terjauh, j + permen[tmp] - N);
      }
    }
    cout << (terbanyak - 1) * N + terjauh;
  }
  cout << endl;
}
