#include <bits/stdc++.h>
using namespace std;
const long long LLINF = 8e18;
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 5000;
int n, m, mx, ans, tmx;
int a[N], b[N], cnt[N], mn1[N], mn2[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  fill(mn1, mn1 + n, INF);
  fill(mn2, mn2 + n, INF);
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (y < x) y += n;
    if (y < mn1[x]) {
      mn2[x] = mn1[x];
      mn1[x] = y;
    } else if (y < mn2[x]) {
      mn2[x] = y;
    }
    cnt[x]++;
    mx = max(mx, cnt[x]);
  }
  for (int i = 0; i < n; i++) {
    ans = (mx - 1) * n;
    tmx = 0;
    for (int j = 0; j < n; j++) {
      if (mn1[j] != INF && cnt[j] == mx) tmx = max(tmx, mn1[j]);
      if (mn1[j] != INF && cnt[j] == mx - 1) tmx = max(tmx, mn1[j] - n);
    }
    ans += tmx - i;
    if (mn1[i] != INF) mn1[i] += n;
    if (mn2[i] != INF) mn2[i] += n;
    cout << ans << ' ';
  }
  return 0;
}
