#include <bits/stdc++.h>
using namespace std;
const int N = 444;
int n, m, a[N], b[N];
vector<int> from[N];
int number;
bool cmp(int u, int v) {
  int du = abs(u - number);
  if (u > number) {
    du = n - du;
  }
  int dv = abs(v - number);
  if (v > number) {
    dv = n - dv;
  }
  return du < dv;
}
void read() {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    from[a[i]].push_back(b[i]);
  }
  for (int i = 0; i < N; ++i) {
    number = i;
    sort(from[i].rbegin(), from[i].rend(), cmp);
  }
}
vector<int> f[N];
int sache[N];
void calc(int ni) {
  int res = 0, mi = m;
  for (int i = 0; i < N; ++i) {
    f[i] = from[i];
    sache[i] = 0;
  }
  while (mi) {
    mi -= sache[ni];
    sache[ni] = 0;
    if (f[ni].size() > 0) {
      sache[f[ni].back()]++;
      f[ni].pop_back();
    }
    ++ni;
    if (ni > n) {
      ni = 1;
    }
    if (mi) {
      ++res;
    }
  }
  cout << res << " ";
}
void solve() {
  read();
  for (int i = 1; i <= n; ++i) {
    calc(i);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  solve();
  return 0;
}
