#include <bits/stdc++.h>
using namespace std;
const long long N = 5e3 + 10;
long long n, m;
vector<long long> v[N];
long long dis(long long a, long long b) {
  if (b < a) return b + n - a;
  return b - a;
}
long long solve(long long indx) {
  long long mx = 0;
  for (long long i = 0; i < n; i++) {
    if (!v[i].size()) continue;
    mx = max(mx, ((long long)v[i].size() - 1) * n + dis(indx, i) +
                     dis(i, v[i].back()));
  }
  return mx;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
  }
  for (long long i = 0; i < N; i++)
    sort(v[i].begin(), v[i].end(),
         [&](long long a, long long b) { return dis(i, a) > dis(i, b); });
  for (long long i = 0; i < n; i++) cout << solve(i) << ' ';
}
