#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> dis(n + 1, n), cnt(n + 1, -1);
  while (m--) {
    int a, b;
    cin >> a >> b;
    ++cnt[a];
    dis[a] = min(dis[a], a > b ? b - a + n : b - a);
  }
  for (int i = 1; i <= n; ++i) {
    int res = 0;
    for (int j = 1; j <= n; ++j)
      if (~cnt[j])
        res = max(res, (i > j ? j - i + n : j - i) + cnt[j] * n + dis[j]);
    cout << res << ' ';
  }
  cout << endl;
}
