#include <bits/stdc++.h>
using namespace std;
const int NN = 5050;
const int MM = 27272;
int a[MM], b[MM];
vector<int> adj[NN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", a + i, b + i);
    adj[a[i]].push_back(b[i]);
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    mx = max(mx, (int)adj[i].size());
    sort(adj[i].begin(), adj[i].end());
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++)
      if (!adj[j].empty()) {
        int it = lower_bound(adj[j].begin(), adj[j].end(), j) - adj[j].begin();
        if (it == adj[j].size()) it = 0;
        int ed = adj[j][it];
        if (ed < j) ed += n;
        if (j < i) ed += n;
        int sz = adj[j].size();
        ans = max(ans, (sz - 1) * n + ed - i);
      }
    cout << ans << ' ';
  }
  return 0;
}
