#include <bits/stdc++.h>
using namespace std;
int amount, candies, max_level = 0;
pair<int, int> station[5005];
int find_result(int start) {
  int total_move = amount * (max_level - 1);
  int plus_now = 0, station_now = start;
  for (int i = 0; i < amount; i++) {
    if (station[station_now].second) {
      int moves_now =
          i + (station[station_now].first - station_now + amount) % amount;
      plus_now =
          max(plus_now, moves_now + (station[station_now].second - 1) * amount);
    }
    station_now = station_now % amount + 1;
  }
  return plus_now;
}
void solve() {
  for (int i = 1; i <= amount; i++) printf("%d ", find_result(i));
}
int main() {
  scanf("%d %d", &amount, &candies);
  for (int i = 1; i <= candies; i++) {
    int start, stop;
    scanf("%d %d", &start, &stop);
    int dist_now = (stop - start + amount) % amount;
    if (!station[start].second ||
        dist_now < (station[start].first - start + amount) % amount)
      station[start].first = stop;
    station[start].second++;
    max_level = max(max_level, station[start].second);
  }
  solve();
}
