#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 5007;
vi adj[N];
void solve() {
  int n, m;
  cin >> n >> m;
  for (ll i = 0; i < (m); i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
  }
  int d[N];
  memset(d, 0, sizeof(d));
  for (int i = 1; i <= n; i++) {
    if (adj[i].size() == 0) continue;
    d[i] = ((int)adj[i].size() - 1) * n;
    int mn = INT_MAX;
    for (int x : adj[i]) {
      int dist = x - i;
      if (dist < 0) dist += n;
      mn = min(mn, dist);
    }
    if (mn == INT_MAX) continue;
    d[i] += mn;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (d[j] == 0) continue;
      int dist = j - i;
      if (dist < 0) dist += n;
      ans = max(ans, d[j] + dist);
    }
    cout << ans << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
