#include <bits/stdc++.h>
using namespace std;
vector<long long> a[1000000];
struct poi {
  int x, id;
} cc[1000000];
long long cmp(const poi &a, const poi &b) { return a.x > b.x; }
long long n, m, x, y, ccc, ans;
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y;
    a[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) cc[i].id = i;
  for (int i = 1; i <= n; i++) {
    long long min1 = 100000000;
    for (int j = 0; j < a[i].size(); j++) {
      if (a[i][j] >= i)
        min1 = min(min1, a[i][j] - i);
      else
        min1 = min(min1, a[i][j] - i + n);
    }
    if (a[i].size() == 0) min1 = 0;
    if (a[i].size() >= 1) cc[i].x += (a[i].size() - 1) * n + min1;
  }
  sort(cc + 1, cc + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 1; j <= n; j++)
      if (cc[j].x) {
        if (-(i - cc[j].id) >= 0)
          ccc = -(i - cc[j].id);
        else
          ccc = -(i - cc[j].id) + n;
        ans = max(ans, ccc + cc[j].x);
      }
    printf("%I64d ", ans);
  }
  return 0;
}
