#include <bits/stdc++.h>
using namespace std;
vector<long long> q[5005];
long long n, m, ans;
long long Calc(long long x, long long y) {
  if (x == y) {
    return 0;
  }
  if (y > x) {
    return y - x;
  }
  return n - x + y;
}
int main() {
  cin >> n >> m;
  long long x, y;
  for (long long i = 0; i < m; i++) {
    scanf("%lld%lld", &x, &y);
    q[x].push_back(y);
  }
  for (long long i = 1; i <= n; i++) {
    ans = 0;
    for (long long j = 1, t = -1; j <= n; j++, t = -1) {
      for (long long k = 0; k < q[j].size(); k++) {
        long long ans = Calc(i, j) + (q[j].size() - 1) * n + Calc(j, q[j][k]);
        if (t == -1) {
          t = ans;
        } else {
          t = min(t, ans);
        }
      }
      ans = max(ans, t);
    }
    printf("%lld ", ans);
  }
  return 0;
}
