#include <bits/stdc++.h>
using namespace std;
int cnt[5001], mini[5001];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<pair<int, int> > v;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    cnt[a]++;
    if (mini[a] == 0)
      mini[a] = a > b ? n - a + b : b - a;
    else
      mini[a] = min(mini[a], a > b ? n - a + b : b - a);
    v.push_back(pair<int, int>(a, b));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int now = 0;
    if (cnt[i]) now = (cnt[i] - 1) * n + mini[i];
    for (int j = i + 1, c = 1;; j++, c++) {
      j %= n;
      if (j == i) break;
      if (cnt[j] > 0) now = max(now, (cnt[j] - 1) * n + mini[j] + c);
    }
    printf("%d ", now);
  }
  return 0;
}
