#include <bits/stdc++.h>
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
long long n, i, j, mx, k;
vector<pair<long long, long long>> m;
vector<long long> v, v2, add;
vector<vector<long long>> have;
bool viv = false;
long long dist(long long a, long long b) {
  long long res = 0;
  res += b;
  res -= a;
  if (res < 0) res += n;
  return res;
}
void counter(long long st) {
  long long res = n;
  for (auto st2 : have[st]) {
    long long nres = dist(st, st2);
    res = min(res, nres);
  }
  add[st] = res;
}
long long solve(long long s) {
  long long ans = n * (mx - 1);
  long long addans = 0;
  for (auto st : v) {
    addans = max(addans, dist(s, st) + add[st]);
  }
  for (auto st : v2) {
    addans = max(addans, dist(s, st) + add[st] - n);
  }
  ans += addans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  have.resize(n);
  for (i = 0; i < k; i++) {
    long long a, b;
    cin >> a >> b;
    a--, b--;
    m.push_back({a, b});
    have[a].push_back(b);
  }
  mx = 0;
  for (long long i = 0; i < n; i++) mx = max(mx, (long long)have[i].size());
  for (long long i = 0; i < n; i++)
    if (have[i].size() == mx) v.push_back(i);
  for (long long i = 0; i < n; i++)
    if (have[i].size() + 1 == mx && have[i].size()) v2.push_back(i);
  add.resize(n, -1);
  for (auto s : v) counter(s);
  for (auto s : v2) counter(s);
  vector<long long> ans;
  for (long long i = 0; i < n; i++) ans.push_back(solve(i));
  for (auto i : ans) cout << i << ' ';
  return 0;
}
