#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, K = 20, mod = 1000000007, MOD = 1000000007;
long long n, m;
long long dis(long long x, long long y) {
  if (!x || !y) return 0;
  if (x <= y) return y - x;
  return n - (x - y);
}
void solve() {
  cin >> n >> m;
  vector<pair<long long, long long> > can(n + 1);
  long long x, y;
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y;
    if (can[x].first == 0)
      can[x].first = y;
    else {
      if (dis(x, can[x].first) > dis(x, y)) can[x].first = y;
    }
    can[x].second++;
  }
  for (long long i = 1; i <= n; i++) {
    long long time = 0;
    for (long long j = 1; j <= n; j++) {
      long long t = dis(i, j) + (can[j].second - 1) * n + dis(j, can[j].first);
      time = max(time, t);
    }
    cout << time << " ";
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
