#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
const int MAXM = 2e4 + 5;
static int N, M, num[MAXN], last[MAXN];
inline int dist(int x, int y) { return y >= x ? y - x : N - x + y; }
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0, s, t; i < M; i++) {
    scanf("%d%d", &s, &t);
    if ((++num[s]) == 1 || dist(s, t) < dist(s, last[s])) last[s] = t;
  }
  for (int i = 1; i <= N; i++) {
    int ans = 0;
    for (int s = 1; s <= N; s++)
      if (num[s])
        ans = max(ans, dist(i, s) + N * (num[s] - 1) + dist(s, last[s]));
    printf("%d ", ans);
  }
  puts("");
  return 0;
}
