#include <bits/stdc++.h>
using namespace std;
int n, m, h[5001], mn[5001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  memset(mn, 0x3f, sizeof(mn));
  for (int i = 0; i < m; ++i) {
    int s, e;
    cin >> s >> e;
    h[s]++;
    mn[s] = min(mn[s], e - s + (e - s < 0 ? n : 0));
  }
  for (int start = 1; start <= n; ++start) {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (h[i] == 0) continue;
      int d = i - start;
      if (d < 0) d += n;
      ans = max(ans, d + (h[i] - 1) * n + mn[i]);
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
