#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000020;
const int K = 60;
const int MOd = 1e9 + 7;
int a, b;
int ar[maxn], T[maxn], mini[maxn];
int main() {
  scanf("%d %d", &a, &b);
  for (int i = 1, j, k; i <= a; i++) mini[i] = 1e9;
  for (int i = 1, j, k; i <= b; i++) {
    scanf("%d %d", &j, &k);
    if (j == k) continue;
    ar[j]++;
    int h = k - j;
    if (h < 0) h += a;
    mini[j] = min(mini[j], (h));
  }
  for (int i = 1, k = 0; i <= a; i++) {
  }
  for (int i = 1; i <= a; i++) {
    int ans = 0, cnt = 0;
    for (int j = i; j <= a; j++) {
      ++cnt;
      if (ar[j]) ans = max(ans, ((ar[j] - 1) * a + (cnt) + mini[j] - 1));
    }
    for (int j = 1; j < i; j++) {
      ++cnt;
      if (ar[j]) ans = max(ans, ((ar[j] - 1) * a + (cnt) + mini[j] - 1));
    }
    cout << ans << " ";
  }
  printf("\n");
  return 0;
}
