#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5 + 5;
const long long int INF = 1e16;
const int l = ceil(log2(LIM));
long long int inf = 1e17;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int> > > queries(n + 1);
  for (long long int i = 1; i <= m; i++) {
    long long int a, b;
    cin >> a >> b;
    long long int d = 0;
    if (b > a)
      d = b - a;
    else
      d = n - a + b;
    queries[a].push_back(pair<int, int>(d, b));
  }
  for (long long int i = 1; i <= n; i++) {
    if (queries[i].size() > 0) sort(queries[i].begin(), queries[i].end());
  }
  vector<long long int> mini(n + 1, -inf);
  for (long long int i = 1; i <= n; i++) {
    long long int k = queries[i].size();
    if (k == 0) continue;
    mini[i] = (k - 1) * n + queries[i][0].first;
  }
  vector<long long int> ans(n + 1, 0);
  for (long long int i = 1; i <= n; i++) {
    ans[i] = mini[i];
    for (long long int j = 1; j <= n; j++) {
      long long int d = 0;
      if (j >= i)
        d = j - i;
      else
        d = n - i + j;
      ans[i] = max(ans[i], mini[j] + d);
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
