#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n + 1, 0);
  vector<int> dist(n + 1, INT_MAX);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    cnt[x]++;
    dist[x] = min(dist[x], (n + y - x) % n);
  }
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (cnt[j]) {
        int t = dist[j] + (cnt[j] - 1) * n + (j - i + n) % n;
        ans = max(ans, t);
      }
    }
    cout << ans << " ";
  }
  return 0;
}
