#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[5005];
int b[5005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < 5001; i++) {
    b[i] = n - 1;
  }
  for (int i = 0; i < m; i++) {
    int c, d;
    cin >> c >> d;
    a[c]++;
    b[c] = min(b[c], (d - c + n) % n);
  }
  for (int i = 1; i <= n; i++) {
    long long res = 0;
    for (int j = 1; j <= n; j++) {
      if (a[j])
        res = max(res, (1ll) * ((j - i + n) % n + (a[j] - 1) * n + b[j]));
    }
    cout << res << " ";
  }
  return 0;
}
