#include <bits/stdc++.h>
using namespace std;
int has[200], pos[200];
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, l, r, ans, need, cnt;
  cin >> n >> m;
  vector<int> v[n];
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    v[l - 1].push_back(r - 1);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < v[i].size(); j++) v[i][j] = (v[i][j] - i + n) % n;
    sort(v[i].rbegin(), v[i].rend());
    for (int j = 0; j < v[i].size(); j++) v[i][j] = (v[i][j] + i) % n;
  }
  for (int i = 0; i < n; i++) {
    cnt = ans = 0;
    need = m;
    fill(has, has + n, 0);
    fill(pos, pos + n, 0);
    for (int j = i; need > 0 || cnt > 0; (j = (j + 1) % n), ans++) {
      cnt -= has[j];
      has[j] = 0;
      if (pos[j] < v[j].size()) {
        has[v[j][pos[j]]]++;
        cnt++;
        pos[j]++;
        need--;
      }
    }
    cout << ans - 1 << " ";
  }
  return 0;
}
