#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3000;
int parent[MAXN];
const long long INF = 1e18;
void make_set(int v) { parent[v] = v; }
int find_set(int v) {
  if (v == parent[v]) return v;
  return find_set(parent[v]);
}
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) parent[b] = a;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> sweets(n);
  for (int i = 0; i < n; i++) {
    sweets[i].assign(n, 0);
  }
  for (int i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--;
    bi--;
    sweets[ai][bi]++;
  }
  for (int i = 0; i < n; i++) {
    auto copy_sweets = sweets;
    int sweets_left = m;
    int cur_pos = i;
    int iters = 0;
    set<int> train;
    while (1) {
      if (train.count(cur_pos)) {
        train.erase(cur_pos);
      }
      int pos = -1;
      for (int i = n - 1; i >= 0; i--) {
        int real_i = (i + cur_pos);
        if (real_i >= n) real_i -= n;
        if (copy_sweets[cur_pos][real_i]) {
          copy_sweets[cur_pos][real_i]--;
          pos = real_i;
          break;
        }
      }
      if (pos != -1) {
        train.insert(pos);
        sweets_left--;
      }
      cur_pos++;
      if (cur_pos == n) {
        cur_pos = 0;
      }
      if (sweets_left || train.size())
        iters++;
      else
        break;
    }
    cout << iters << " ";
  }
}
int main(int argc, char** argv) { solve(); }
