#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = 0;
  long long x = 0, flag = 1;
  while (!isdigit(ch)) {
    ch = getchar();
    if (ch == '-') flag = -1;
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * flag;
}
struct edge {
  long long to, nxt;
} e[110000 * 2];
long long num, head[110000];
inline void add(long long x, long long y) {
  e[++num] = (edge){y, head[x]};
  head[x] = num;
}
long long go[110000], cnt[110000];
int main() {
  long long n = read(), m = read();
  num = -1;
  memset(head, -1, sizeof(head));
  for (long long i = 1; i <= m; i++) {
    long long x = read(), y = read();
    add(x, y);
    cnt[x]++;
  }
  for (long long x = 1; x <= n; x++) {
    go[x] = 1e9 + 7;
    for (long long i = head[x]; i != -1; i = e[i].nxt) {
      long long to = e[i].to;
      go[x] = min(go[x], ((to - x) % n + n) % n);
    }
  }
  for (long long o = 1; o <= n; o++) {
    long long ans = 0;
    for (long long x = 1; x <= n; x++)
      if (cnt[x]) {
        long long dis = ((x - o) % n + n) % n;
        ans = max(ans, (cnt[x] - 1) * n + dis + go[x]);
      }
    printf("%lld ", ans);
  }
  return 0;
}
