#include <bits/stdc++.h>
using namespace std;
int n, m;
int toycnt[5050];
int minway[5050];
int dist(int s, int t) { return (t >= s ? t - s : n + t - s); }
int main(void) {
  memset(minway, 0x3f, sizeof(minway));
  scanf("%d%d", &n, &m);
  while (m--) {
    int s, t;
    scanf("%d%d", &s, &t);
    toycnt[s]++;
    minway[s] = min(minway[s], dist(s, t));
  }
  for (int sp = 1; sp <= n; sp++) {
    int ans = 0;
    for (int np = 1; np <= n; np++) {
      if (toycnt[np] == 0) continue;
      ans = max(ans, dist(sp, np) + n * (toycnt[np] - 1) + minway[np]);
    }
    printf("%d ", ans);
  }
  return 0;
}
