#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 10;
int n, m;
int r1, c1, r2, c2;
int g[55][55];
int find(VI &f, int x) { return f[x] == x ? x : f[x] = find(f, f[x]); }
void uni(VI &f, int x, int y) { f[find(f, x)] = find(f, y); }
int dis(int a, int b, int n) { return (n + b - a) % n; }
void MAIN() {
  cin >> n >> m;
  vector<PII> carry(n);
  int g[n][n];
  memset(g, 0, sizeof(g));
  for (int i = (0); i < (m); i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u][v]++;
  }
  { ((void)0); }
  { ((void)0); }
  for (int i = (0); i < (n); i++) {
    int use[n][n];
    memset(use, 0, sizeof(use));
    int res = 0;
    int d = 0;
    int cur = i;
    int cnt = 0;
    while (cnt < m || d > 0) {
      int best_v = -1;
      for (int j = (0); j < (n); j++)
        if (use[cur][j] < g[cur][j] &&
            (best_v == -1 || dis(cur, j, n) > dis(cur, best_v, n)))
          best_v = j;
      if (best_v != -1) {
        cnt++;
        { ((void)0); }
        amax(d, dis(cur, best_v, n));
        use[cur][best_v]++;
        { ((void)0); };
      }
      if (d) d--;
      res++;
      cur += 1;
      cur %= n;
    }
    cout << res << " ";
  }
  cout << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int TC = 1;
  for (int tc = (0); tc < (TC); tc++) {
    MAIN();
  }
  return 0;
}
