#include <bits/stdc++.h>
using namespace std;
int mod = 20100501;
const int maxn = 5e4 + 10;
const int ub = 1e6;
long long powmod(long long x, long long y) {
  long long t;
  for (t = 1; y; y >>= 1, x = x * x % mod)
    if (y & 1) t = t * x % mod;
  return t;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
int n, m, INF;
int x[maxn], y[maxn];
int cnt[maxn], flag[maxn], mv[maxn];
int main() {
  cin >> n >> m;
  memset((mv), (0xf), sizeof(mv)), INF = mv[0];
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
    cnt[x[i]]++;
    int len = (y[i] - x[i] + n) % n;
    if (len < mv[x[i]]) mv[x[i]] = len;
  }
  for (int(i) = (0); (i) < (n); (i)++) {
    int ans = 0;
    for (int(j) = (0); (j) < (n); (j)++) {
      if (mv[j] == INF) continue;
      int tp1 = (j - i + n) % n, tp2 = tp1 + mv[j];
      ans = max(ans, (cnt[j] - 1) * n + tp2);
    }
    cout << ans << " ";
  }
  puts("");
  return 0;
}
