#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> A, B;
vector<vector<int> > POS;
vector<queue<int> > Q;
void precompute() {
  POS = vector<vector<int> >(N);
  for (int j = 0, _n = (M); j < _n; ++j) {
    int u = A[j] - 1, v = B[j] - 1;
    POS[u].push_back(v);
  }
  Q = vector<queue<int> >(N);
  for (int u = 0, _n = (N); u < _n; ++u) {
    if (POS[u].empty()) continue;
    sort(POS[u].begin(), POS[u].end());
    auto it = lower_bound(POS[u].begin(), POS[u].end(), u);
    vector<int> P;
    for (int j = 0, _n = (int((POS[u]).size())); j < _n; ++j) {
      if (it == POS[u].end()) it = POS[u].begin();
      P.push_back(*it);
      it++;
    }
    reverse(P.begin(), P.end());
    for (int x : P) Q[u].push(x);
  }
}
bool trace;
long long solve(int start) {
  long long res = 0;
  set<int> train;
  vector<int> to(N, -1);
  auto QQ = Q;
  for (int i = start, rem_candies = M;; i = (i + 1) % N) {
    train.erase(i);
    if (!QQ[i].empty()) {
      --rem_candies;
      train.insert(QQ[i].front());
      QQ[i].pop();
    }
    if (rem_candies == 0 && train.empty()) break;
    res++;
  }
  return res;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  cin >> N >> M;
  A = vector<int>(M);
  B = vector<int>(M);
  for (int j = 0, _n = (M); j < _n; ++j) {
    cin >> A[j] >> B[j];
  }
  precompute();
  for (int start = 0, _n = (N); start < _n; ++start) {
    long long res = solve(start);
    cout << res << ' ';
  }
  cout << endl;
  return 0;
}
