#include <bits/stdc++.h>
using namespace std;
long long int c, n;
bool cmp(long long int a, long long int b) {
  long long int ta = a, tb = b;
  if (a < c) ta += n;
  if (b < c) tb += n;
  return ta > tb;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int m;
  cin >> n >> m;
  vector<pair<long long int, long long int> > t(m);
  for (long long int i = 0; i < m; i++) cin >> t[i].first >> t[i].second;
  vector<vector<long long int> > v(n);
  for (long long int i = 0; i < m; i++)
    v[t[i].first - 1].push_back(t[i].second - 1);
  for (long long int i = 0; i < n; i++)
    c = i, sort(v[i].begin(), v[i].end(), cmp);
  for (long long int i = 0; i < n; i++) {
    long long int ans = 0;
    for (long long int j = 0; j < n; j++) {
      if (v[j].size() == 0) continue;
      long long int d = 0;
      if (i <= j)
        d += j - i;
      else
        d += j + n - i;
      d += (v[j].size() - 1) * n;
      long long int dest = v[j].back();
      if (dest > j)
        d += dest - j;
      else
        d += dest + n - j;
      ans = max(ans, d);
    }
    cout << ans << " ";
  }
  return 0;
}
