#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& _o_, const vector<T>& _v_) {
  if (!_v_.empty()) {
    _o_ << '[';
    copy(_v_.begin(), _v_.end(), ostream_iterator<T>(_o_, ", "));
    _o_ << "\b\b]";
  }
  return _o_;
}
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using umap = unordered_map<T, U>;
template <typename T>
using uset = unordered_set<T>;
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using max_heap = priority_queue<T>;
int n, m;
V<int> a, b;
V<V<int>> c;
int rdist(int x, int y) {
  if (x <= y) return y - x;
  return n - x + y;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  a.resize(m);
  b.resize(m);
  c.resize(n);
  for (__typeof(m) i = (0) - ((0) > (m)); i != (m) - ((0) > (m));
       i += 1 - 2 * ((0) > (m))) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
    c[a[i]].push_back(b[i]);
  }
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    sort(c[i].begin(), c[i].end(),
         [&](int x, int y) { return rdist(i, x) < rdist(i, y); });
  }
  for (__typeof(n) start = (0) - ((0) > (n)); start != (n) - ((0) > (n));
       start += 1 - 2 * ((0) > (n))) {
    int total_dist = INT_MIN;
    for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
         i += 1 - 2 * ((0) > (n))) {
      int dist = 0;
      V<int>& v = c[i];
      if (v.size() == 0) {
        dist = 0;
      } else if (v.size() == 1) {
        dist = rdist(start, i) + rdist(i, v[0]);
      } else {
        dist = rdist(start, i) + rdist(i, v[0]) + n * (v.size() - 1);
      }
      total_dist = max(total_dist, dist);
    }
    if (start != 0) cout << ' ';
    cout << total_dist;
  }
  cout << '\n';
}
