#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > candies;
vector<int> stations[105];
int findDiff(int nxt, int cur) {
  int ans;
  if (nxt < cur) {
    ans = (n - cur) + nxt;
  } else
    ans = nxt - cur;
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int ai, bi;
    cin >> ai >> bi;
    candies.push_back(make_pair(ai, bi));
  }
  for (int i = 0; i < m; i++) {
    int ai = candies[i].first;
    stations[ai].push_back(i);
  }
  map<int, int> empty_stations;
  for (int i = 1; i <= n; i++) {
    if (stations[i].size() == 0) empty_stations[i] = 1;
  }
  map<int, int> train;
  map<int, int> chosen;
  for (int start = 1; start <= n; start++) {
    int cur_station = start;
    long long ans = 0;
    while (1) {
      if (train.find(cur_station) != train.end()) {
        train.erase(cur_station);
      }
      int chosen_candy = -1;
      int bi_max = 0;
      for (int i = 0; i < stations[cur_station].size(); i++) {
        int candy_idx = stations[cur_station][i];
        int bi = candies[candy_idx].second;
        if (chosen.find(candy_idx) == chosen.end() &&
            findDiff(bi, cur_station) > bi_max) {
          bi_max = findDiff(bi, cur_station);
          chosen_candy = candy_idx;
        }
      }
      if (chosen_candy != -1) {
        chosen[chosen_candy] = 1;
        train[candies[chosen_candy].second] = 1;
      }
      bool isEmpty = true;
      for (int i = 0; i < stations[cur_station].size(); i++) {
        int candy_idx = stations[cur_station][i];
        if (chosen.find(candy_idx) == chosen.end()) {
          isEmpty = false;
        }
      }
      if (isEmpty) {
        empty_stations[cur_station] = 1;
      }
      if (empty_stations.size() == n) {
        int finalcost = 0;
        for (map<int, int>::iterator it = train.begin(); it != train.end();
             it++) {
          int bi = it->first;
          int curcost = findDiff(bi, cur_station);
          finalcost = max(finalcost, curcost);
        }
        ans += finalcost;
        break;
      }
      cur_station = (cur_station) % n + 1;
      ans++;
    }
    cout << ans << " ";
    empty_stations.clear();
    train.clear();
    chosen.clear();
    for (int i = 1; i <= n; i++) {
      if (stations[i].size() == 0) empty_stations[i] = 1;
    }
  }
  cout << endl;
  return 0;
}
