#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, m;
int cnt[N], mn[N];
inline int dis(int a, int b) { return (b + n - a) % n; }
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  memset(mn, -1, sizeof(mn));
  for (int i = 1; i <= m; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    ++cnt[t1];
    if (mn[t1] == -1 || mn[t1] > dis(t1, t2)) mn[t1] = dis(t1, t2);
  }
  for (int i = 1; i <= n; i++) {
    int ans = -1;
    for (int j = 1; j <= n; j++)
      if (cnt[j]) ans = max(ans, n * (cnt[j] - 1) + dis(i, j) + mn[j]);
    cout << ans << ' ';
  }
  return 0;
}
