#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long tinf = (long long)1e9 + 7;
const long long inf = (long long)1e18 + 7;
const long long N = 7e5 + 5;
const long long M = 1e9 + 7;
const long long rx[4] = {1, 0, -1, 0};
const long long ry[4] = {0, 1, 0, -1};
signed main() {
  {
    ios ::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  }
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > d[n];
  for (long long i = 0; i < m; i++) {
    long long v, u;
    cin >> v >> u;
    v--;
    u--;
    long long dist = 0;
    if (u >= v)
      dist = u - v;
    else
      dist = n - v + u;
    d[v].push_back({dist, u});
  }
  for (long long i = 0; i < n; i++) {
    sort(d[i].rbegin(), d[i].rend());
  }
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    if ((long long)d[i].size()) v.push_back(i);
  }
  for (long long i = 0; i < n; i++) {
    long long ans = 0;
    for (auto j : v) {
      long long dist = 0;
      if (j >= i)
        dist = j - i;
      else
        dist = n - i + j;
      ans =
          max(ans, d[j].back().first + dist + ((long long)d[j].size() - 1) * n);
    }
    cout << ans << " ";
  }
}
