#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void showpq(priority_queue<int> gq) {
  priority_queue<int> g = gq;
  while (!g.empty()) {
    cout << '\t' << g.top();
    g.pop();
  }
  cout << '\n';
}
void solve() {
  int n, m;
  cin >> n >> m;
  priority_queue<int> stations[n];
  for (long long i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    if (v < u) v += n;
    stations[u].push(v);
  }
  for (long long i = 0; i < n; i++) {
    int start = i;
    int del_count = 0;
    multiset<int> train;
    priority_queue<int> tmp[n];
    for (long long i = 0; i < n; i++) tmp[i] = stations[i];
    while (del_count < m) {
      if (!tmp[start % n].empty()) {
        train.insert(tmp[start % n].top() % n);
        tmp[start % n].pop();
      }
      del_count += train.erase(start % n);
      start++;
    }
    cout << start - i - 1 << ' ';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
