#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int ma[n], vu[n];
  memset(ma, 0, sizeof ma);
  memset(vu, 0, sizeof vu);
  int po, de, ca;
  while (m--) {
    scanf("%d %d", &po, &de);
    po--;
    de--;
    if (de < po) de += n;
    ca = de - po;
    vu[po]++;
    if (ma[po] == 0 || ca < ma[po]) ma[po] = ca;
  }
  int i, j, j2, maxi;
  for (i = 0; i < n; i++) {
    maxi = 0;
    for (j = 0; j < n; j++)
      if (vu[j]) {
        j2 = j;
        if (j2 < i) j2 += n;
        ca = (vu[j] - 1) * n + ma[j] + j2 - i;
        if (ca > maxi) maxi = ca;
      }
    printf("%d", maxi);
    if (i < n - 1)
      printf(" ");
    else
      printf("\n");
  }
  return 0;
}
