#include <bits/stdc++.h>
using namespace std;
vector<int> adj[300007], old_adj[300007];
int cnt[300007];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (auto i = (1); i <= (m); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    old_adj[x].emplace_back(y);
  }
  for (auto start = (1); start <= (n); ++start) {
    int m_ = m;
    int ans = -1;
    for (auto i = (1); i <= (n); ++i) adj[i] = old_adj[i];
    int i = start - 1;
    while (1) {
      ++ans;
      ++i;
      if (i > n) i = 1;
      m_ -= cnt[i];
      cnt[i] = 0;
      if (!m_) break;
      int trace = -1;
      int max_dist = INT_MIN;
      for (auto j = (0); j <= ((int)adj[i].size() - 1); ++j) {
        int u = adj[i][j];
        int dist = u - i;
        if (dist < 0) dist += n;
        if (dist > max_dist) {
          max_dist = dist;
          trace = j;
        }
      }
      if (trace != -1) {
        ++cnt[adj[i][trace]];
        adj[i][trace] = adj[i].back();
        adj[i].pop_back();
      }
    }
    printf("%d ", ans);
  }
  return 0;
}
