#include <bits/stdc++.h>
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const int LOGN = 20;
vector<int> d[5002], td[5002];
int n, m, dest[5002];
int dst(int a, int b) {
  if (b < a) b += n;
  ;
  return b - a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= (m); i++) {
    int s, t;
    cin >> s >> t;
    d[s].push_back(t);
  }
  for (int i = 1; i <= (n); i++)
    if (d[i].size() > 1) {
      vector<pair<int, int> > v;
      for (int x : d[i]) {
        v.push_back(make_pair(dst(i, x), x));
      }
      sort(v.begin(), v.end());
      d[i].clear();
      for (pair<int, int> p : v) d[i].push_back(p.second);
    }
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++) {
      td[j] = d[j];
      dest[j] = 0;
    }
    int del = 0, cur = i;
    int tim = 0, book = 0;
    while (1) {
      if (td[cur].size() > 0) {
        del++;
        book++;
        dest[td[cur].back()]++;
        td[cur].pop_back();
      }
      book -= dest[cur];
      dest[cur] = 0;
      if (del == m && book == 0) {
        break;
      }
      tim++;
      cur++;
      if (cur > n) cur = 1;
    }
    cout << tim << " ";
  }
  return 0;
}
