#include <bits/stdc++.h>
#pragma comment(linker, "/stack:256000000")
using namespace std;
mt19937_64 gen(time(NULL));
long long const maxn = 2e5 + 5;
vector<long long> kek[maxn];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  vector<long long> a(m), b(m);
  for (long long i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    kek[a[i]].push_back(b[i]);
  }
  for (long long i = 0; i < n; i++) {
    sort(kek[i].begin(), kek[i].end(), [&](long long j, long long j1) {
      return (j >= i ? j - i : j - i + n) < (j1 >= i ? j1 - i : j1 - i + n);
    });
  }
  vector<long long> rofl(n);
  for (long long i = 0; i < n; i++) {
    if (kek[i].size()) {
      rofl[i] = n * (kek[i].size() - 1) +
                (kek[i][0] >= i ? kek[i][0] - i : kek[i][0] - i + n);
    }
  }
  vector<long long> ans(n);
  for (long long i = 0; i < n; i++) {
    long long mx = 0;
    for (long long j = 0; j < n; j++) {
      if (rofl[j] == 0) continue;
      mx = max(mx, rofl[j] + (j >= i ? j - i : j - i + n));
    }
    ans[i] = mx;
  }
  for (auto now : ans) {
    cout << now << " ";
  }
  return 0;
}
