#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 998244353;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll binpow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
ll modInv(ll a) { return binpow(a, MOD - 2); }
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 5001;
pair<int, int> arr[mxN];
vector<int> pos[mxN];
int worst[mxN];
int n, m;
int main() {
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m;
  int a, b;
  for (int i = (0); i < (m); ++i) {
    cin >> a >> b;
    a--;
    b--;
    pos[a].push_back(b);
  }
  for (int i = (0); i < (n); ++i) {
    if (pos[i].size() > 0) {
      worst[i] = INF;
    }
    for (int k : pos[i]) {
      worst[i] = min(worst[i], (n + k - i) % n);
    }
  }
  for (int i = (0); i < (n); ++i) {
    int ans = 0;
    for (int j = (0); j < (n); ++j) {
      int sz = pos[j].size() - 1;
      if (sz >= 0) {
        ans = max(ans, (n + j - i) % n + n * (sz) + worst[j]);
      }
    }
    cout << (ans) << " ";
  }
  cout << "\n";
  return 0;
}
