#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 1LL;
void solve();
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) solve();
  return 0;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> out[n];
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    a--, b--;
    out[a].push_back(b);
  }
  long long dp[n][n];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (i == j)
        dp[i][j] = 0;
      else if (i < j)
        dp[i][j] = j - i;
      else
        dp[i][j] = n - (i - j);
    }
  }
  for (long long i = 0; i < n; i++) {
    long long res = 0;
    long long j = i;
    do {
      if (out[j].empty()) {
        j = (j + 1) % n;
        continue;
      }
      long long dis = dp[i][j] + (out[j].size() - 1) * n;
      long long check = inf;
      for (auto x : out[j]) {
        check = min(check, dis + dp[j][x]);
      }
      res = max(res, check);
      j = (j + 1) % n;
    } while (j != i);
    cout << res << " ";
  }
  cout << "\n";
  return;
}
