#include <bits/stdc++.h>
using namespace std;
long long distance(int a, int b, int n) {
  long long d = 0;
  if (a <= b) {
    d += b - a;
  } else {
    long long temp = (n - a) + 1;
    d += temp + b - 1;
  }
  return d;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  int i, j;
  for (int i = 0; i < int(m); i++) {
    cin >> a[i] >> b[i];
  }
  vector<long long> p(n + 1, INT_MAX);
  vector<long long> out(n + 1);
  for (i = 0; i < m; i++) {
    out[a[i]]++;
  }
  for (i = 1; i <= n; i++) {
    if (out[i] > 0) {
      for (j = 0; j < m; j++) {
        if (a[j] == i) {
          long long temp = n * (out[i] - 1) + distance(i, b[j], n);
          p[i] = min(p[i], temp);
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    long long ans = -1;
    for (j = 1; j <= n; j++) {
      if (out[j] > 0) {
        long long temp = p[j] + distance(i, j, n);
        ans = max(ans, temp);
      }
    }
    cout << ans << " ";
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
