#include <bits/stdc++.h>
using namespace std;
int n, m;
int gn(int id) { return (id + 1) % n; }
const int MAXN = 5100;
int lst[MAXN];
int sed[MAXN];
vector<int> v[MAXN];
int dis(int st, int ed) {
  if (ed < st) ed += n;
  return ed - st;
}
int go(int st, int step) { return (st + step) % n; }
int cnt[5100] = {0};
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int st, ed;
    scanf("%d%d", &st, &ed);
    st--, ed--;
    v[st].push_back(dis(st, ed));
  }
  int maxx = 0;
  for (int i = 0; i < n; i++) {
    sort(v[i].begin(), v[i].end());
    maxx = max(maxx, (int)v[i].size());
  }
  for (int i = 0; i < n; i++) {
    long long ans = 0;
    for (int j = 0; j < n; j++) {
      long long now = 0;
      if (v[j].size() == 0)
        now = 0;
      else
        now = dis(i, j) + (v[j].size() - 1) * n * 1LL + v[j][0];
      ans = max(ans, now);
    }
    if (i) printf(" ");
    printf("%I64d", ans);
  }
}
