#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename Arg1>
void debug(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void debug(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1;
  debug(comma, args...);
}
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
vector<long long> arr[5001];
long long n, m, mx = 0;
map<long long, long long> last;
long long dist(long long i, long long b) {
  long long cd;
  if (b >= i)
    cd = b - i;
  else
    cd = n - i + b;
  return cd;
}
void solve(long long st) {
  long long mxans = 0;
  for (long long a = 1; a <= n; ++a) {
    if (arr[a].size() == 0) continue;
    long long b = last[a];
    long long sz = arr[a].size();
    long long curans = dist(st, a) + b + (sz - 1) * n;
    mxans = max(mxans, curans);
  }
  cout << mxans << ' ';
}
int32_t main() {
  c_p_c();
  cin >> n >> m;
  while (m--) {
    long long a, b;
    cin >> a >> b;
    arr[a].push_back(b);
    long long crsz = arr[a].size();
    mx = max(mx, crsz);
  }
  for (long long i = 1; i <= n; ++i) {
    if (arr[i].size()) {
      long long mxdst = 1e18;
      for (long long id = 0; id < arr[i].size(); ++id) {
        long long b = arr[i][id];
        long long cd = dist(i, b);
        mxdst = min(mxdst, cd);
      }
      last[i] = mxdst;
    }
  }
  for (long long st = 1; st <= n; ++st) solve(st);
  return 0;
}
