#include <bits/stdc++.h>
using namespace std;
int n;
int dist(int s, int d) {
  if (d >= s)
    return d - s;
  else
    return n - (s - d);
}
int main() {
  int m, maxd = 0, d[5010], cntmax = 0, di[5010];
  vector<int> g[5010];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) di[i] = 1000000000;
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    maxd = max(maxd, (int)g[i].size());
    for (auto v : g[i])
      if (dist(i, v) < di[i]) {
        d[i] = v;
        di[i] = dist(i, v);
        cntmax++;
      }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (g[j].size())
        ans = max(ans, dist(i, j) + ((int)g[j].size() - 1) * n + di[j]);
    }
    cout << ans << ' ';
  }
  return 0;
}
