#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> S[5005];
int Times[5005], L[5005];
int dist(int x, int y) {
  if (x <= y)
    return y - x;
  else
    return y + (n - x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    S[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    int minim = 1e9;
    for (auto j : S[i]) {
      if (dist(i, j) < minim) minim = dist(i, j), L[i] = j;
    }
  }
  for (int i = 1; i <= n; i++) {
    memset(Times, 0, sizeof(Times));
    int st = i;
    int maxim = -1, wh;
    for (int j = 1; j <= n; j++) {
      int sz = S[st].size();
      if (sz >= maxim) {
        maxim = S[st].size();
        wh = st;
      }
      st++;
      if (st == n + 1) st = 1;
    }
    long long pasi = 0;
    st = i;
    if (maxim >= 1) {
      st = i;
      int ok = 1;
      for (int j = 1; j <= n; j++) {
        Times[st] = ok + maxim - 1;
        if (st == wh) ok = 0;
        st++;
        if (st == n + 1) st = 1;
      }
      pasi = dist(i, wh) + (maxim - 1) * n;
      st = wh;
    }
    int maxim2 = 0;
    for (int i = 1; i <= n; i++) {
      if (Times[i] > S[i].size()) continue;
      if (dist(i, L[i]) <= dist(i, wh)) continue;
      if (dist(wh, L[i]) > maxim2) maxim2 = dist(wh, L[i]);
    }
    pasi += maxim2;
    cout << pasi << " ";
  }
  return 0;
}
