#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
int cnt[5025], minn[5025];
int main() {
  int a, b, n, m, maxx = 0, maxx_;
  scanf("%d%d", &n, &m);
  memset(minn, 0x3f, sizeof(int) * (n + 1));
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    cnt[a]++, maxx = max(maxx, cnt[a]);
    minn[a] = min(minn[a], (b - a + n) % n);
  }
  for (int i = 1; i <= n; ++i) {
    int st = 0;
    long long tmp, ans = 0;
    maxx_ = 0;
    for (int j = 1; j <= n; ++j) {
      tmp = 0;
      if (cnt[j] == 0) continue;
      tmp += (j - i + n) % n + (cnt[j] - 1) * n + minn[j];
      ans = max(tmp, ans);
    }
    printf("%lld ", ans);
  }
  return 0;
}
