#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 10;
vector<long long> v[111];
void solve(long long start, long long c, long long colStantion) {
  long long kol = c;
  vector<long long> b[111];
  for (int i = 0; i < colStantion; ++i) {
    b[i] = v[i];
  }
  long long ans = 0;
  long long t = 0;
  long long stantion = start;
  while (true) {
    if (b[stantion].size() > 0) {
      t = max(t, b[stantion][b[stantion].size() - 1]);
      b[stantion].pop_back();
      kol--;
    }
    if (kol == 0) {
      break;
    }
    t--;
    stantion++;
    if (stantion == colStantion) stantion = 0;
    ans++;
  }
  cout << ans + t << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    if (x > y)
      v[x].push_back(n - x + y);
    else
      v[x].push_back(y - x);
  }
  for (int i = 0; i < n; ++i) {
    sort(v[i].begin(), v[i].end());
  }
  for (int i = 0; i < n; ++i) {
    solve(i, m, n);
  }
}
