#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<long long, long long>;
const ll MAXN = 100001;
const ll MAXK = 26 * 2;
const ll MAXM = 1e5 + 3;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ld EPS = 1e-9;
const ll INF = numeric_limits<int>::max() / 4;
const ll MSIZE = 20;
const ld pi = acos(-1.0);
const ll H = 8;
void precalc() {}
vector<pair<ll, ll>> items[5011];
ll n, m;
ll solve_for(ll index) {
  ll answer = 0;
  for (ll i = 0; i < n; ++i) {
    ll curr = 0;
    if (items[i].size() > 0) {
      curr += i >= index ? i - index : i - index + n;
      curr += n * (items[i].size() - 1);
      curr += items[i].back().first;
    }
    answer = max(curr, answer);
  }
  return answer;
}
void solve() {
  cin >> n >> m;
  for (ll i = 0; i < m; ++i) {
    ll a, b;
    cin >> a >> b;
    ll dist = b >= a ? b - a : b - a + n;
    items[a - 1].push_back({dist, b - 1});
  }
  for (ll i = 0; i < n; ++i) {
    sort(items[i].rbegin(), items[i].rend());
  }
  for (ll i = 0; i < n; ++i) {
    cout << solve_for(i) << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(20);
  precalc();
  solve();
}
