#include <bits/stdc++.h>
using namespace std;
struct sw {
  long long t, d;
};
bool operator<(sw sw1, sw sw2) { return sw1.d < sw2.d; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, a, b, cnt[100], cntg, res, cur, ptr[100], time;
  cin >> n >> m;
  vector<vector<sw> > e(n);
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    sw sw1;
    sw1.t = b;
    sw1.d = (b - a + n) % n;
    e[a].push_back(sw1);
  }
  for (int i = 0; i < n; i++) {
    sort(e[i].begin(), e[i].end());
    reverse(e[i].begin(), e[i].end());
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cnt[j] = 0;
      ptr[j] = 0;
    }
    cntg = 0;
    res = 0;
    cur = i;
    time = 0;
    while (res < m) {
      cntg -= cnt[cur];
      res += cnt[cur];
      cnt[cur] = 0;
      if (res == m) break;
      time++;
      if (ptr[cur] < e[cur].size()) {
        cnt[e[cur][ptr[cur]].t]++;
        ptr[cur]++;
        cntg++;
      }
      cur = (cur + 1) % n;
    }
    cout << time << " ";
  }
}
