#include <bits/stdc++.h>
using namespace std;
int n;
struct Compare {
  bool operator()(pair<int, int> a, pair<int, int> b) {
    int da = (a.first < a.second ? a.second - a.first : n - a.first + a.second);
    int db = (b.first < b.second ? b.second - b.first : n - b.first + b.second);
    if (da < db) return true;
    return false;
  }
};
int main() {
  int m;
  cin >> n >> m;
  vector<priority_queue<pair<int, int>, vector<pair<int, int>>, Compare>> v(n +
                                                                            1);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].emplace(a, b);
  }
  for (int i = 1; i <= n; i++) {
    vector<priority_queue<pair<int, int>, vector<pair<int, int>>, Compare>> c =
        v;
    int cnt = m, cur = i, ans = 0;
    vector<int> on(n + 1);
    while (cnt) {
      if (on[cur]) cnt -= on[cur], on[cur] = 0;
      if (c[cur].size()) on[c[cur].top().second]++, c[cur].pop();
      if (cnt) ans++;
      cur++;
      if (cur > n) cur = 1;
    }
    cout << ans << " ";
  }
  return 0;
}
