#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[20010];
int b[20010];
int cc[5010];
int ttl[5010];
int ans[5010];
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    ttl[i] = n;
  }
  for (int i = 0; i < m; i++) {
    cc[a[i]]++;
    int nt;
    if (b[i] > a[i]) {
      nt = b[i] - a[i];
    } else {
      nt = n - a[i] + b[i];
    }
    ttl[a[i]] = min(ttl[a[i]], nt);
  }
  for (int i = 1; i <= n; i++) {
    if (cc[i] == 0) {
      ttl[i] = 0;
    } else {
      ttl[i] += (cc[i] - 1) * n;
    }
  }
  multiset<int> s;
  for (int i = 1; i <= n; i++) {
    if (ttl[i] > 0) {
      s.insert(ttl[i] + i - 1);
    }
  }
  ans[0] = *(--s.end());
  for (int i = 1; i < n; i++) {
    if (ttl[i] > 0) {
      s.erase(s.find(ttl[i] + i - 1));
      s.insert(ttl[i] + i + n - 1);
    }
    ans[i] = *(--s.end()) - i;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
