#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long dist(long long a, long long b) {
  if (b >= a) return b - a;
  return b - a + n;
}
int main() {
  cin >> n >> m;
  vector<long long> last(n + 1, n + 10), freq(n + 1);
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    freq[a]++;
    last[a] = min(last[a], dist(a, b));
  }
  for (long long beg = 1; beg <= n; beg++) {
    long long ans = -1;
    for (long long i = 1; i <= n; i++) {
      if (freq[i] == 0) continue;
      long long curr = dist(beg, i);
      curr += (n * (freq[i] - 1));
      curr += last[i];
      ans = max(ans, curr);
      ;
    }
    cout << ans << " ";
  }
  cout << "\n";
}
