#include <bits/stdc++.h>
using namespace std;
int n, m, far[5005], deg[5005], ans[5005];
int d(int x, int y) {
  if (y >= x)
    return y - x;
  else
    return n - (x - y);
}
int main() {
  scanf("%d%d", &n, &m);
  fill(far + 1, far + n + 1, 1000000000);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    far[x] = min(far[x], d(x, y));
    deg[x]++;
  }
  for (int i = 1; i <= n; i++)
    if (!deg[i]) far[i] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      ans[i] = max(ans[i], d(i, j) + (deg[j] - 1) * n + far[j]);
    }
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
