#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
int a[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(a, -1, sizeof(a));
  for (int i = 0, x, y; i < m; ++i)
    scanf("%d%d", &x, &y),
        a[x] = (a[x] + n - 1) / n * n + min((a[x] + n) % n, (y + n - x) % n);
  for (int i = 1, ans; i <= n; ++i) {
    ans = 0;
    for (int j = 1; j <= n; ++j)
      if (a[j] != -1) ans = max(ans, a[j] + (j + n - i) % n);
    printf("%d%c", ans, i == n ? '\n' : ' ');
  }
  return 0;
}
