#include <bits/stdc++.h>
using namespace std;
int a[5001], c[5001];
int n, m, x, y, mg = 0;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &x, &y);
    if (x == y) continue;
    if (c[x] == 0) a[x] = 1000000009;
    c[x]++;
    mg = max(mg, c[x]);
    int d = y;
    if (y < x) d += n;
    a[x] = min(a[x], d);
  }
  if (mg == 0) {
    for (int i = 1; i <= n; i++) {
      printf("0 ");
    }
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] > 0) a[i] += (c[i] - 1) * n;
  }
  for (int i = 1; i <= n; i++) {
    int mx = 0;
    for (int j = 1; j <= n; j++) {
      a[j]--;
      if (c[j] > 0) mx = max(mx, a[j]);
    }
    printf("%d ", mx);
    a[i] += n;
  }
  return 0;
}
