#include <bits/stdc++.h>
using namespace std;
vector<long long int> ar1[6005];
vector<long long int> v1[6005];
long long int n;
long long int m;
long long int calc(long long int s) {
  long long int ctr = m;
  long long int ret = 0;
  for (long long int i = 1; i <= n; i++) {
    v1[i].clear();
    for (long long int j = 0; j < ar1[i].size(); j++) {
      v1[i].push_back(ar1[i][j]);
    }
  }
  map<long long int, long long int> destination;
  while (ctr * 1 > 0) {
    if (v1[s].size() > 0) {
      long long int t = 0, v = v1[s][0] - s;
      if (v * 1 < 0) {
        v += n;
      }
      for (long long int j = 0; j < v1[s].size(); j++) {
        long long int ctr1 = v1[s][j] - s;
        if (ctr1 < 0) {
          ctr1 += n;
          ctr1 += 0;
        }
        if (ctr1 > v) {
          v = ctr1;
          t = j;
        }
      }
      destination[v1[s][t]]++;
      v1[s].erase(v1[s].begin() + t);
    }
    ctr -= destination[s];
    if (ctr == 0) break;
    destination[s] = 0;
    s++;
    ret++;
    if (s == (n + 1)) s = 1;
  }
  return ret;
}
int main() {
  scanf("%lld%lld", &n, &m);
  long long int aa, bb;
  vector<pair<long long int, long long int> > arr(m);
  for (long long int i = 0; i < m; i++) {
    scanf("%lld%lld", &aa, &bb);
    arr[i].first = aa;
    arr[i].second = bb;
    ar1[arr[i].first].push_back(arr[i].second);
  }
  for (long long int i = 1; i <= n; i++) {
    sort(ar1[i].begin(), ar1[i].end());
  }
  for (long long int j = 1; j <= n; j++) {
    printf("%lld ", calc(j));
  }
  printf("\n");
  return 0;
}
