#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
const int MOD = 1e9 + 7;
int t[500500];
int dist[500500];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  memset(dist, INF, sizeof(dist));
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    t[a]++;
    dist[a] = min(dist[a], (b - a + n) % n);
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (t[j]) {
        ans = max(ans, (t[j] - 1) * n + dist[j] + (j - i + n) % n);
      }
    }
    cout << ans << " ";
  }
}
