#include <bits/stdc++.h>
using namespace std;
int n;
int distancia(int a, int b) {
  if (b == a) return 0;
  if (b < a) return n - a + b;
  return b - a;
}
int main() {
  int m, a, b, ans = 0, dist;
  int menor[105], qtd[105] = {0};
  memset(menor, 0x3f3f3f3f, sizeof menor);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    qtd[a]++;
    menor[a] = min(distancia(a, b), menor[a]);
  }
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 1; j <= n; j++) {
      if (menor[j] != 0x3f3f3f3f && qtd[j] > 0) {
        dist = (qtd[j] - 1) * n + menor[j] +
               (j >= i ? distancia(i, j) : n - distancia(j, i));
        if (dist > ans) {
          ans = dist;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
