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