#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, m, a, b, s[5100];
vector<int> g[5100];
int dis(int x, int y) {
  if (x <= y)
    return y - x;
  else
    return n - x + y;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
  }
  for (int i = 1; i <= n; i++) {
    if (int((g[i]).size())) s[i] = INF;
    for (auto t : g[i]) {
      s[i] = min(s[i], (int((g[i]).size()) - 1) * n + dis(i, t));
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (s[j]) ans = max(ans, dis(i, j) + s[j]);
    }
    cout << ans << ' ';
  }
  return 0;
}
