#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
vector<int> v[MAXN];
int ans[MAXN];
int main() {
  int n, m;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    v[x].emplace_back(y);
  }
  for (int i = 1; i <= n; i++) {
    int t = (v[i].size() - 1) * n;
    int tmp = 0x3f3f3f3f;
    for (auto tt : v[i])
      if (tt > i)
        tmp = min(tmp, tt - i);
      else
        tmp = min(tmp, tt + n - i);
    if (tmp == 0x3f3f3f3f) continue;
    t += tmp;
    ans[i] = max(ans[i], t);
    int j = i - 1;
    t++;
    if (j == 0) j = n;
    while (j != i) {
      ans[j] = max(ans[j], t);
      t++;
      j--;
      if (j <= 0) j += n;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}
