#include <bits/stdc++.h>
using namespace std;
long long n, ans, a, b, m, tt, mx, v[5005], szs[5005], add;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    v[a] = min(v[a] ? v[a] : (long long)1e18, (b - a + n) % n);
    szs[a]++;
    mx = max(mx, szs[a]);
  }
  ans = (mx - 2) * n;
  for (long long i = 1; i < n + 1; i++) {
    add = 0;
    for (long long j = 1; j < n + 1; j++) {
      tt = 0;
      if (szs[j] && szs[j] >= mx - 1) tt = ((j - i + n) % n) + v[j];
      tt += n * (szs[j] == mx);
      add = max(add, tt);
    }
    cout << ans + add << " ";
  }
  return 0;
}
