#include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
void solve() {
  long long int n, m;
  cin >> n >> m;
  long long int same = m;
  map<long long int, vector<long long int>> store1;
  while (m--) {
    long long int a, b;
    cin >> a >> b;
    store1[a].push_back(b);
    sort(store1[a].begin(), store1[a].end());
  }
  for (auto &p : store1) {
    sort(p.second.begin(), p.second.end(),
         [&](const long long int &i, const long long int &j) {
           return (i - p.first + n) % n < (j - p.first + n) % n;
         });
  }
  multiset<long long int> s;
  long long int count = 0;
  for (long long int i = 1; i <= n; i++) {
    map<long long int, vector<long long int>> store = store1;
    s.clear();
    count = 0;
    long long int j = i;
    m = same;
    while (m > 0) {
      if (j > n) {
        j = 1;
      }
      if (s.count(j)) {
        m -= s.count(j);
        s.erase(j);
      }
      if (!store[j].empty()) {
        s.insert(store[j].back());
        store[j].pop_back();
      }
      j++;
      count++;
    }
    cout << count - 1 << " ";
  }
  cout << '\n';
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
