#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  out << '(' << p.first << ',' << p.second << ')';
  return out;
}
template <class T1, class T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) in >> x;
  return in;
}
template <class T>
ostream& operator<<(ostream& out, vector<vector<T>>& v) {
  for (auto& x : v) out << x << '\n';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto x : v) out << x << ' ';
  return out;
}
long long gcd(long long a, long long b) {
  if (b > a) swap(a, b);
  return (b ? gcd(b, a % b) : a);
}
const long double pi = 2 * asin(1);
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.setstate(ios::failbit);
  int n, m;
  cin >> n >> m;
  map<int, pair<int, int>> M;
  for (register int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (!M.count(x))
      M[x] = make_pair((y + n - x) % n, 1);
    else
      M[x].first = min(M[x].first, (y + n - x) % n), M[x].second++;
  }
  vector<int> ans(n);
  for (auto x : M)
    for (register int i = 1; i < n + 1; i++)
      ans[i - 1] = max(ans[i - 1], (x.second.second - 1) * n +
                                       (x.first + n - i) % n + x.second.first);
  cout << ans;
}
