#include <bits/stdc++.h>
using namespace std;
int n, m, a[100010], b[100010], v[100010], ans[100010], pre[100010],
    suff[100010];
vector<pair<int, int> > edge[100010];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    int dis = 0;
    if (a[i] < b[i])
      dis = b[i] - a[i];
    else
      dis = n - a[i] + b[i];
    edge[a[i]].push_back(make_pair(dis, b[i]));
  }
  for (int i = 0; i < n; i++) {
    sort(edge[i].begin(), edge[i].end());
    if (edge[i].empty())
      v[i] = -(1 << 30);
    else
      v[i] = i + n * (edge[i].size() - 1) + edge[i][0].first;
  }
  for (int i = n - 1; i >= 0; i--)
    suff[i] = max((i < n - 1) ? suff[i + 1] : -(1 << 30), v[i]);
  for (int i = 0; i < n; i++) pre[i] = max(i ? pre[i - 1] : -(1 << 30), v[i]);
  for (int i = 0; i < n; i++) {
    int ans1 = i ? (pre[i - 1] + (n - i)) : -(1 << 30);
    int ans2 = suff[i] - i;
    cout << max(ans1, ans2) << " ";
  }
}
