#include <bits/stdc++.h>
using namespace std;
int k[50000], a, b, num[50000], n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    if (!num[a])
      num[a] = b;
    else {
      k[a]++;
      if ((b + n - a) % n < (num[a] + n - a) % n) num[a] = b;
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++)
      if (num[j])
        ans = max(ans, (j + n - i) % n + k[j] * n + (num[j] + n - j) % n);
    cout << ans << " ";
  }
  return 0;
}
