#include <bits/stdc++.h>
using namespace std;
const int MAX = 200006;
long long arr[5005], cnt[5005];
int n, m;
long long dis(int a, int b) {
  if (a == b) return 0;
  if (b > a) return b - a;
  return n - a + b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> m;
  memset(arr, -1, sizeof arr);
  while (m--) {
    int a, b;
    cin >> a >> b;
    if (arr[a] == -1)
      arr[a] = dis(a, b);
    else {
      arr[a] = min(arr[a], dis(a, b));
    }
    cnt[a]++;
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    for (int j = 1; j <= n; j++) {
      if (cnt[j]) {
        ans = max(ans, dis(i, j) + (cnt[j] - 1) * n + arr[j]);
      }
    }
    cout << ans << " ";
  }
  cout << "\n";
}
