#include <bits/stdc++.h>
using namespace std;
int main() {
  int candy[5010];
  memset(candy, 0x3f, sizeof(candy));
  int N, M, cnt[5010] = {0}, ans;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) {
    int s, e;
    scanf("%d%d", &s, &e);
    candy[s] = min(candy[s], (e + N - s) % N);
    cnt[s]++;
  }
  for (int i = 1; i <= N; i++) {
    ans = 0;
    for (int j = 1; j <= N; j++) {
      if (cnt[j]) ans = max(ans, candy[j] + (j + N - i) % N + (cnt[j] - 1) * N);
    }
    printf("%d", ans);
    if (i != N) printf(" ");
  }
  return 0;
}
