#include <bits/stdc++.h>
using namespace std;
const int M = 6e3;
const int inf = 0x3f3f3f3f;
int n, m, a, b;
int cnt[M], mn[M];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int mx = 0, maxx = 0;
  cin >> n >> m;
  memset(mn, inf, sizeof(mn));
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if (b < a) b += n;
    if (b - a < mn[a]) mn[a] = b - a;
    cnt[a]++;
  }
  for (int i = 1; i <= n; i++) {
    maxx = 0;
    for (int j = 1; j <= n; j++) {
      if (cnt[j]) {
        if (j < i)
          maxx = max(maxx, j + n - i + mn[j] + (cnt[j] - 1) * n);
        else
          maxx = max(maxx, j - i + mn[j] + (cnt[j] - 1) * n);
      }
    }
    cout << maxx << endl;
  }
  return 0;
}
