#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 5050, INF = 0x3f3f3f3f;
int n, m, a, b, ans[MAXN], temp[MAXN], ming[MAXN], minall[MAXN], cnt[MAXN];
int main() {
  memset(ming, INF, sizeof ming);
  memset(minall, INF, sizeof minall);
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &a, &b), cnt[a]++;
    minall[a] = min(minall[a], b);
    if (b > a) ming[a] = min(ming[a], b);
  }
  for (int i = 1; i <= n; ++i) {
    temp[i] = 0;
    if (cnt[i] == 0) continue;
    temp[i] += (cnt[i] - 1) * n;
    if (ming[i] != INF)
      temp[i] += ming[i] - i;
    else
      temp[i] += (n - i) + minall[i];
  }
  for (int i = 1; i <= n; ++i) {
    ans[i] = 0;
    for (int j = 1; j <= n; ++j) {
      if (!temp[j]) continue;
      if (j >= i)
        ans[i] = max(ans[i], temp[j] + j - i);
      else
        ans[i] = max(ans[i], temp[j] + (n - i) + j);
    }
  }
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  printf("\n");
}
