#include <bits/stdc++.h>
using namespace std;
int n, m;
int cnt[5010], len[5010];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) len[i] = n;
  while (m--) {
    int a, b;
    scanf("%d %d", &a, &b);
    cnt[a]++;
    if (b < a) b += n;
    len[a] = min(len[a], b - a);
  }
  for (int i = 1; i <= n; i++) {
    int ans = (cnt[i] - 1) * n + len[i];
    for (int j = i + 1; j <= n; j++) {
      if (cnt[j]) ans = max(ans, (cnt[j] - 1) * n + len[j] + j - i);
    }
    for (int j = 1; j < i; j++) {
      if (cnt[j]) ans = max(ans, (cnt[j] - 1) * n + len[j] + n - i + j);
    }
    printf("%d", ans);
    putchar(i == n ? '\n' : ' ');
  }
  return 0;
}
