#include <bits/stdc++.h>
using namespace std;
long long int n, m;
long long int st;
vector<long long int> v[105];
bool check(long long int num) {
  for (long long int i = 1; i <= n; i++) {
    if (v[i].size() == 0) continue;
    long long int tleft;
    if (st <= i)
      tleft = num - (i - st);
    else
      tleft = num - (n - (st - i));
    if (tleft <= 0) return false;
    long long int r = tleft / n;
    long long int left = tleft % n;
    if (v[i].size() <= r) continue;
    if (v[i].size() > r + 1) return false;
    long long int x = lower_bound(v[i].begin(), v[i].end(), i) - v[i].begin();
    if (lower_bound(v[i].begin(), v[i].end(), i) == v[i].end()) x = 0;
    long long int temp = v[i][x];
    long long int ttake;
    if (temp >= i)
      ttake = temp - i;
    else
      ttake = n - (i - temp);
    if (left < ttake) return false;
  }
  return true;
}
long long int binsearch() {
  long long int low = 0, high = 1e5;
  while (low < high) {
    long long int mid = (low + high) / 2;
    if (check(mid))
      high = mid;
    else
      low = mid + 1;
  }
  return low;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long int i = 1; i <= m; i++) {
    long long int x, y;
    cin >> x >> y;
    if (x == y) continue;
    v[x].push_back(y);
  }
  for (long long int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (long long int i = 1; i <= n; i++) {
    st = i;
    cout << binsearch() << " ";
  }
  return 0;
}
