#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, tren, pos[N], cnt[N];
vector<int> g[N];
int dist(int a, int tr) {
  if (a > tr)
    return a - tr;
  else
    return n + a - tr;
}
bool cmp(int a, int b) {
  if (dist(a, tren) < dist(b, tren)) return true;
  return false;
}
int next(int i) {
  if (i < n) return i + 1;
  return 1;
}
int check(int i) {
  int num = 0, curr = i, time = 0;
  while (num < m) {
    if (cnt[curr]) {
      num += cnt[curr];
      cnt[curr] = 0;
    }
    if (pos[curr] >= 0) {
      cnt[g[curr][pos[curr]]]++;
      pos[curr]--;
    }
    curr = next(curr);
    time++;
  }
  return time - 1;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    tren = i;
    sort(g[i].begin(), g[i].end(), cmp);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cnt[j] = 0;
      pos[j] = g[j].size() - 1;
    }
    printf("%d ", check(i));
  }
  return 0;
}
