#include <bits/stdc++.h>
using namespace std;
int tmp, n;
bool comp(int x, int y) {
  int dx = tmp < x ? x - tmp : n - tmp + x;
  int dy = tmp < y ? y - tmp : n - tmp + y;
  return dx < dy;
}
void solve() {
  int m;
  cin >> n >> m;
  vector<int> v[n];
  for (int i = 0; i < (m); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    v[a].push_back(b);
  }
  for (int i = 0; i < (n); ++i) {
    tmp = i;
    sort(v[i].begin(), v[i].end(), comp);
  }
  for (int i = 0; i < (n); ++i) {
    int pos = i, cnt = 0, res = 0, tgt = -1;
    vector<int> p(n);
    for (int j = 0; j < (n); ++j) p[j] = v[j].size();
    while (cnt != m) {
      if (pos == tgt) tgt = -1;
      if (p[pos] == 0) {
        ++pos;
        ++res;
        if (pos == n) pos = 0;
        continue;
      }
      int b = v[pos][p[pos] - 1];
      p[pos]--;
      ++cnt;
      if (tgt == -1)
        tgt = b;
      else if (tgt > pos) {
        if (b > pos)
          tgt = max(tgt, b);
        else
          tgt = b;
      } else {
        if (b < pos) tgt = max(tgt, b);
      }
      if (cnt != m) {
        ++pos;
        ++res;
        if (pos == n) pos = 0;
      }
    }
    if (tgt != -1)
      while (pos != tgt) {
        pos++;
        ++res;
        if (pos == n) pos = 0;
      }
    cout << res << " ";
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
