#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const double err = 1e-9;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
int n, m;
int p, t, ct;
int stg[101];
int x, y;
vi ba[101];
stack<int> st[101];
int stm[101];
void stcopy() {
  for (int(i) = (0); (i) < (n); (i)++) {
    for (int(j) = (0); (j) < ((int)(ba[i]).size()); (j)++) st[i].push(ba[i][j]);
  }
}
int dis(int a, int b) {
  if (b < a)
    return n - a + b;
  else
    return b - a;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int(i) = (0); (i) < (m); (i)++) {
    cin >> x >> y;
    x--;
    y--;
    ba[x].push_back(y);
  }
  for (int(i) = (0); (i) < (n); (i)++) {
    sort(ba[i].begin(), ba[i].end(),
         [&](int a, int b) { return dis(i, a) < dis(i, b); });
  }
  for (int(i) = (0); (i) < (n); (i)++) {
    stcopy();
    memset(stg, 0, sizeof stg);
    p = i;
    ct = 0;
    t = 0;
    while (ct < m) {
      if (stg[p]) ct += stg[p], stg[p] = 0;
      if ((int)(st[p]).size() > 0) stg[st[p].top()]++, st[p].pop();
      p = (p + 1) % n;
      if (ct < m) t++;
    }
    stm[i] = t;
  }
  for (int(i) = (0); (i) < (n); (i)++) cout << stm[i] << ' ';
  cout << endl;
  return 0;
}
