#include <bits/stdc++.h>
using namespace std;
int n, m;
int jl(int x, int y) {
  if (x <= y) return y - x;
  return y + n - x;
}
int CNT[5005], ZJ[5005];
int ans;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) ZJ[i] = n;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    CNT[a]++;
    ZJ[a] = min(ZJ[a], jl(a, b));
  }
  for (int i = 1; i <= n; i++) {
    ans = 0;
    if (CNT[i]) ans = max(ans, (CNT[i] - 1) * n + ZJ[i]);
    for (int j = 1; j <= n; j++) {
      if ((!CNT[j]) || (i == j)) continue;
      ans = max(ans, jl(i, j) + (CNT[j] - 1) * n + ZJ[j]);
    }
    printf("%d ", ans);
  }
}
