#include <bits/stdc++.h>
const long long Inf = 1e18;
long long LINF = (long long)2e18;
using namespace std;
long long mod = 1e9 + 7;
long long mod3 = 998244353;
long long mod2 = 1e9 + 123;
const int maxn = 1e5 + 5;
long long dis[maxn];
long long cnt[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < maxn; i++) {
    cnt[i] = 0, dis[i] = LINF;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    long long tmp = x > y ? (y - x + n) : (y - x);
    dis[x] = min(dis[x], tmp);
    cnt[x]++;
  }
  for (int i = 1; i <= n; i++) {
    long long ans = -LINF;
    for (int j = 1; j <= n; j++)
      if (dis[j] != LINF)
        ans = max(ans, n * (cnt[j] - 1) + dis[j] + (j - i + n) % n);
    if (ans != -LINF)
      printf("%I64d ", ans);
    else
      printf("0 ");
  }
  return 0;
}
