#include <bits/stdc++.h>
using std::max;
using std::min;
const int N = 5010;
int n, m, p[N], mx, cnt[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int a, b, i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    if (b < a) b += n;
    ++cnt[a];
    mx = max(cnt[a], mx);
    p[a] = p[a] ? min(p[a], b - a) : b - a;
  }
  int ans = (mx - 1) * n;
  for (int i = 1; i <= n; i++) {
    int yuu = 0;
    for (int j = i; j <= n; j++) {
      if (cnt[j] == mx)
        yuu = max(yuu, j + p[j] - i);
      else if (cnt[j] == mx - 1) {
        int tp = j + p[j];
        if (tp > n) tp -= n;
        if (tp > j) continue;
        yuu = max(yuu, tp - i);
      }
    }
    for (int j = 1; j < i; j++) {
      if (cnt[j] == mx)
        yuu = max(yuu, j + p[j] + n - i);
      else if (cnt[j] == mx - 1) {
        int tp = j + p[j];
        yuu = max(yuu, tp - i);
      }
    }
    printf("%d ", ans + yuu);
  }
  return 0;
}
