#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
const int INF = 1e9 + 5;
int n, m;
vector<int> out, mini;
int dist(int a, int b) {
  if (b < a) b += n;
  return b - a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  out = vector<int>(n + 1, 0);
  mini = vector<int>(n + 1, INF);
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    out[a]++;
    mini[a] = min(mini[a], dist(a, b));
  }
  int ans;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    for (int j = 1; j <= n; j++) {
      if (out[j] == 0) continue;
      ans = max(ans, dist(i, j) + (out[j] - 1) * n + mini[j]);
    }
    cout << ans << ' ';
  }
  cout << '\n';
  return 0;
}
