#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
long long n, m, a, b, t;
long long out[5001];
long long dist[5001][5001];
long long min_dist[5001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      dist[i][j] = j - i + n * (j < i);
    }
  }
  for (int i = 0; i < 5001; i++) min_dist[i] = 1e18;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    out[a]++;
    min_dist[a] = min(min_dist[a], dist[a][b]);
  }
  for (int k = 1; k < n + 1; k++) {
    t = 0;
    for (int i = 1; i < n + 1; i++) {
      if (out[i]) t = max(t, dist[k][i] + n * (out[i] - 1) + min_dist[i]);
    }
    cout << t << " ";
  }
}
