#include <bits/stdc++.h>
using namespace std;
long long numberOfCandies[5005];
long long closestOne[5005];
long long dist[5005];
long long distStartBefore[5005];
long long n, m;
int main() {
  cin >> n >> m;
  memset(numberOfCandies, 0, sizeof(numberOfCandies));
  memset(closestOne, -1, sizeof(closestOne));
  memset(dist, 0, sizeof(dist));
  long long source, destination, distance;
  for (long i = 0; i < m; i++) {
    cin >> source >> destination;
    numberOfCandies[source]++;
    distance = destination - source;
    if (distance < 0) distance += n;
    if (distance < closestOne[source] || closestOne[source] < 1)
      closestOne[source] = distance;
  }
  long long maxDist = 0;
  for (long index = 1; index <= n; index++) {
    if (numberOfCandies[index] > 0) {
      dist[index] =
          (numberOfCandies[index] - 1) * n + (index - 1) + closestOne[index];
      if (dist[index] > maxDist) maxDist = dist[index];
    }
  }
  for (long index = 0; index < n; index++) {
    if (dist[index] > 0) {
      dist[index] += n;
      if (dist[index] > maxDist) maxDist = dist[index];
    }
    cout << maxDist - index << " ";
  }
  return 0;
}
