#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 100;
const long long INF = 1e18;
const long long MOD = 998244353;
long long n, m;
long long r(long long from, long long to) {
  if (from <= to) {
    return to - from;
  } else {
    return n - from + to;
  }
}
void solve() {
  cin >> n >> m;
  vector<vector<long long>> c(n + 1);
  for (int i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    c[a].push_back(b);
  }
  vector<long long> ans(n + 1);
  for (int i = 1; i <= n; ++i) {
    sort((c[i]).begin(), (c[i]).end());
  }
  for (int i = 1; i <= n; ++i) {
    long long cur = 0;
    for (int j = i; j <= n; ++j) {
      if (c[j].size() == 0) continue;
      long long curcur = INF;
      for (int k = 0; k < c[j].size(); ++k) {
        curcur = min(
            curcur, ((long long)c[j].size() - 1) * n + r(j, c[j][k]) + r(i, j));
      }
      cur = max(cur, curcur);
    }
    for (int j = 1; j < i; ++j) {
      if (c[j].size() == 0) continue;
      long long curcur = INF;
      for (int k = 0; k < c[j].size(); ++k) {
        curcur = min(
            curcur, ((long long)c[j].size() - 1) * n + r(j, c[j][k]) + r(i, j));
      }
      cur = max(cur, curcur);
    }
    ans[i] = cur;
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long test = 1;
  while (test--) solve();
  return 0;
}
