#include <bits/stdc++.h>
using namespace std;
const int maxn = 5001;
int p[maxn][2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  int a, b, res = 0, d;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (a > b) b = n + b;
    d = b - a;
    if (p[a][1] == 0 || p[a][0] > d) p[a][0] = d;
    p[a][1]++;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (!p[j][1]) continue;
      if (i > j)
        d = n - i + j;
      else
        d = j - i;
      ans = max(ans, p[j][0] + (p[j][1] - 1) * n + d);
    }
    cout << ans << " ";
  }
  cout << "\n";
  return 0;
}
