#include <bits/stdc++.h>
using namespace std;
bool endline = false;
bool endline2 = false;
bool space = true;
template <class T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &i : v) {
    in >> i;
  }
  return in;
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (auto i : v) {
    out << i;
    if (!endline2) {
      if (space) {
        cout << ' ';
      }
    } else {
      cout << '\n';
    }
  }
  if (endline && !endline2) cout << '\n';
  return out;
}
template <class T, class U>
istream &operator>>(istream &in, pair<T, U> &a) {
  in >> a.first >> a.second;
  return in;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &a) {
  out << a.first << ' ' << a.second;
  return out;
}
int n, m;
vector<pair<int, int>> v;
vector<vector<int>> g;
long long get(int cur) {
  long long res = -1;
  vector<vector<int>> t = g;
  int cnt = 0;
  multiset<int> s;
  while (cnt < m) {
    res++;
    if (t[cur].size() > 0) {
      s.insert(t[cur].back());
      t[cur].pop_back();
    }
    cnt += s.count(cur);
    s.erase(cur);
    cur = (cur + 1) % n;
  }
  return res;
}
int l;
bool comp(int a, int b) {
  int to_a = (n + a - l) % n, to_b = (n + b - l) % n;
  return to_a < to_b;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  v.resize(m);
  g.resize(n, vector<int>());
  for (int i = 0; i < m; i++) {
    cin >> v[i];
    v[i].first--;
    v[i].second--;
    g[v[i].first].push_back(v[i].second);
  }
  for (int i = 0; i < n; i++) {
    l = i;
    sort(g[i].begin(), g[i].end(), comp);
  }
  for (int i = 0; i < n; i++) {
    long long temp = get(i);
    cout << temp << ' ';
  }
  return 0;
}
