#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using i64 = long long;
using i32 = int;
using f64 = long double;
template <class Key>
using vec = vector<Key>;
template <class Key>
using heap = priority_queue<Key>;
template <class Key>
using hash_set = unordered_set<Key>;
template <class Key, class Value>
using hash_map = unordered_map<Key, Value>;
using str = string;
template <size_t Size1>
using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2>
using aa64 = array<a64<Size2>, Size1>;
template <size_t Size1, size_t Size2, size_t Size3>
using aaa64 = array<aa64<Size2, Size3>, Size1>;
using p64 = pair<i64, i64>;
using v64 = vec<i64>;
using vv64 = vec<v64>;
using s64 = set<i64>;
using m64 = map<i64, i64>;
mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;
template <typename T>
inline i64 sz(const T& a) {
  return (i64)(a.size());
}
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <typename T>
inline bool check_min(T& a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <typename T>
inline bool check_max(T& a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
struct Problem {
  Problem(bool multitest = 0) {
    read();
    if (!multitest) solve();
  }
  void solve(), read();
};
signed main() {
  fast();
  Problem();
  return 0;
}
i64 n, m;
v64 a, b;
vv64 c;
i64 dist(i64 from, i64 to) { return (to - from + n) % n; }
void Problem::solve() {
  c.resize(n);
  for (i64 i = 0; i < m; i++) {
    c[a[i]].push_back(dist(a[i], b[i]));
  }
  for (i64 i = 0; i < sz(c); i++) {
    sort((c[i]).begin(), (c[i]).end());
  }
  for (i64 i = 0; i < n; i++) {
    i64 ans = 0;
    for (i64 j = 0; j < n; j++) {
      if (c[j].empty()) continue;
      i64 cur = dist(i, j) + (sz(c[j]) - 1) * n + c[j][0];
      check_max(ans, cur);
    }
    cout << ans << " ";
  }
}
void Problem::read() {
  cin >> n >> m;
  a.resize(m), b.resize(m);
  for (i64 i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
  }
}
