#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
using dd = double;
using ldd = long double;
using si = short int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> cnt(n), lens(n, 1e9);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    ++cnt[a];
    lens[a] = min(lens[a], (b - a + n) % n);
  }
  0;
  0;
  int ma = 0;
  for (int i = 0; i < n; ++i) {
    ma = max(ma, cnt[i]);
  }
  for (int fir = 0; fir < n; ++fir) {
    int ans = 0;
    for (int to = 0; to < n; ++to) {
      if (cnt[to] == 0) continue;
      int d = (cnt[to] - 1) * n;
      d += (to - fir + n) % n;
      d += lens[to];
      ans = max(ans, d);
    }
    cout << ans << '\n';
  }
  return 0;
}
