#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> v[110];
  for (long long i = 0; i < m; i++) {
    long long s, t;
    cin >> s >> t;
    s--;
    t--;
    v[s].push_back((t + n - s) % n);
  }
  long long size = 0;
  for (long long i = 0; i < n; i++) size = max(size, (long long)v[i].size());
  for (long long i = 0; i < n; i++)
    sort(v[i].begin(), v[i].end(), greater<long long>());
  long long ans2[110] = {};
  for (long long k = 0; k < 2; k++) {
    for (long long start = 0; start < n; start++) {
      long long ans = (size - 1) * n;
      long long tmp = 0;
      for (long long step = 0; step < n; step++) {
        long long now = (start + step) % n;
        if (v[now].size() != size) continue;
        tmp = max(tmp, v[now][size - 1] + step);
      }
      ans2[start] = max(ans2[start], ans + tmp);
    }
    if (size == 1) break;
    size--;
  }
  for (long long i = 0; i < n; i++) {
    if (i != 0) cout << " ";
    cout << ans2[i];
  }
  cout << endl;
  return 0;
}
