#include <bits/stdc++.h>
using namespace std;
vector<int> vec[101];
int n, m;
int dist(int a, int b) {
  int v = b - a;
  if (v < 0) v += n;
  return v;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    vec[a].push_back(b);
  }
  for (int i = 0; i < n; i++) {
    sort(vec[i].begin(), vec[i].end());
    auto k = upper_bound(vec[i].begin(), vec[i].end(), i);
    if (k != vec[i].end()) rotate(vec[i].begin(), k, vec[i].end());
    reverse(vec[i].begin(), vec[i].end());
  }
  for (int i = 0; i < n; i++) {
    int k = 0;
    int pos = i;
    int mxd = -1;
    vector<int> cnt(n);
    int ttl = 0;
    while (k < m || mxd != -1) {
      if (cnt[pos] < (int)vec[pos].size()) {
        if (mxd != -1) {
          int dmxd = mxd - pos;
          int dcur = vec[pos][cnt[pos]] - pos;
          if (dmxd < 0) dmxd += n;
          if (dcur < 0) dcur += n;
          if (dmxd < dcur) mxd = vec[pos][cnt[pos]];
        } else {
          mxd = vec[pos][cnt[pos]];
        }
        cnt[pos]++;
        k++;
      }
      if (mxd == pos) {
        mxd = -1;
      }
      pos = (pos + 1) % n;
      ttl++;
    }
    printf("%d ", ttl - 1);
  }
  printf("\n");
  return 0;
}
