#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 5010;
const long long INF = 2000000100;
const long long MOD = 998244353;
int N, M, I, K, S, ans;
vector<int> cand[MAXN];
int vis[MAXN];
int diff(int a, int b) { return (b - a + N) % N; }
bool comp(int A, int B) {
  return (I < A && A < B) || (A < B && B < I) || (B < I && I < A);
}
int sim(int n) {
  int step = 0;
  int a = 0;
  for (int i = n; step < N; i = (i + 1) % N, step++) {
    for (int j = 0; j < (int)cand[i].size(); j++) {
      int c = cand[i][j];
      int r = step + j * N + diff(i, c);
      a = max(a, r);
    }
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> M;
  int a, b;
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    cand[a - 1].push_back(b - 1);
  }
  for (int n = 0; n < N; n++) {
    I = n;
    sort(cand[n].begin(), cand[n].end(), comp);
    K = max(K, (int)cand[n].size());
  }
  for (int n = 0; n < N; n++) {
    for (int i = 0; i < K - 2 && !cand[n].empty(); i++) {
      cand[n].pop_back();
    }
    if ((int)cand[n].size() == 2) {
      swap(cand[n][0], cand[n][1]);
    }
    S += cand[n].size();
  }
  ans = max((K - 2) * N, 0);
  for (int n = 0; n < N; n++) {
    cout << ans + sim(n) << (n == N - 1 ? "\n" : " ");
  }
}
