#include <bits/stdc++.h>
using namespace std;
using LD = long double;
using PLL = pair<long long, long long>;
using VII = vector<pair<int, int> >;
template <class T>
istream& operator>>(istream& st, vector<T>& container) {
  for (auto& u : container) st >> u;
  return st;
}
template <class T>
ostream& operator<<(ostream& st, const vector<T>& container) {
  for (auto& u : container) st << u << '\n';
  return st;
}
template <class T, size_t N>
istream& operator>>(istream& st, array<T, N>& container) {
  for (auto& u : container) st >> u;
  return st;
}
template <class T, size_t N>
ostream& operator<<(ostream& st, const array<T, N>& container) {
  for (auto u : container) st << u << ' ';
  return st;
}
template <class T, class U>
istream& operator>>(istream& st, pair<T, U>& p) {
  st >> p.first >> p.second;
  return st;
}
template <class T, class U>
ostream& operator<<(ostream& st, pair<T, U> p) {
  st << p.first << ' ' << p.second;
  return st;
}
template <class T, class U, class V>
pair<T, U> operator*(pair<T, U> p, V val) {
  return {p.first * val, p.second * val};
}
template <class T, class U, class V>
pair<T, U> operator/(pair<T, U> p, V val) {
  return {p.first / val, p.second / val};
}
template <class T, class U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return {a.first - b.first, a.second - b.second};
}
template <class T, class U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return {a.first + b.first, a.second + b.second};
}
template <class T>
T dotProduct(pair<T, T> a, pair<T, T> b) {
  return a.first * b.first + a.second * b.second;
}
template <class T>
T crossProduct(pair<T, T> a, pair<T, T> b) {
  return a.first * b.second - a.second * b.first;
}
template <class T>
T distPow(pair<T, T> a) {
  return a.first * a.first + a.second * a.second;
}
template <class T>
LD dist(pair<T, T> a) {
  return sqrt(distPow(a));
}
const int N = (int)5e3 + 57, inf = (int)1e9 + 7;
const long long MOD = (long long)1e9 + 7;
const long long INF = (long long)1e18 + 7;
const int M = 1 << 20;
const long double PI = acos(-1);
const LD EPS = 1e-12;
vector<int> cukierki[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout << fixed << setprecision(9);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    b -= a;
    if (b < 0) b += n;
    cukierki[a].push_back(b);
  }
  for (int i = 0; i < n; ++i) sort(begin((cukierki[i])), end((cukierki[i])));
  for (int s = 0; s < n; ++s) {
    long long ileKolek = 0;
    long long res = 0;
    int j = s;
    for (int i = 0; i < n; ++i) {
      if (ileKolek < (int)cukierki[j].size() - 1) {
        ileKolek = (int)cukierki[j].size() - 1;
      }
      if (cukierki[j].size())
        res = max(res, n * ((long long)cukierki[j].size() - 1) + i +
                           cukierki[j].front());
      j++;
      if (j == n) j = 0;
    }
    cout << res << ' ';
  }
}
