#include <bits/stdc++.h>
long long mod = 1000000007;
using namespace std;
long long int fast_exp(long long int base, long long int ex) {
  long long int res = 1;
  while (ex > 0) {
    if (ex % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    ex /= 2;
  }
  return res % mod;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a[m];
  long long b[m];
  long long mi[n];
  long long sz[n];
  for (int i = 0; i < n; i++) {
    mi[i] = 1e17;
    sz[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    long long h = b[i] - a[i];
    if (h < 0) h += n;
    mi[a[i]] = min(mi[a[i]], h);
    sz[a[i]]++;
  }
  long long ti[n];
  memset(ti, 0, sizeof(ti));
  for (int i = 0; i < n; i++) {
    long long p = 0;
    if (sz[i]) {
      p += sz[i] - 1LL;
      p *= n;
      p += mi[i];
    }
    ti[i] = p;
  }
  for (int i = 0; i < n; i++) {
    long long to = 0;
    for (int j = 0; j < n; j++) {
      long long u = j - i;
      if (u < 0) u += n;
      u += ti[j];
      if (sz[j]) to = max(to, u);
    }
    cout << to << " ";
  }
  return 0;
}
