#include <bits/stdc++.h>
using namespace std;
int pos_mod(int x, int n) { return ((x % n) + n) % n; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> stations(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    stations[a - 1].push_back(b - 1);
  }
  vector<int> ncandy(n);
  vector<int> min_dist(n);
  int max_candy = 0;
  for (int i = 0; i < n; i++) {
    ncandy[i] = stations[i].size();
    max_candy = max(max_candy, ncandy[i]);
    if (stations[i].empty()) {
      min_dist[i] = 0;
    } else {
      min_dist[i] = INT_MAX;
      for (int j : stations[i]) {
        min_dist[i] = min(min_dist[i], pos_mod((j - i), n));
      }
    }
  }
  vector<int> top_stations;
  vector<int> subtop_stations;
  for (int i = 0; i < n; i++) {
    if (ncandy[i] == max_candy)
      top_stations.push_back(i);
    else if (ncandy[i] == max_candy - 1)
      subtop_stations.push_back(i);
  }
  for (int start = 0; start < n; start++) {
    int dist = 0;
    for (int i : subtop_stations) {
      int dist_to_start = pos_mod(start - i, n);
      if (dist_to_start == 0) dist_to_start = n;
      dist = max(dist, min_dist[i] - dist_to_start);
    }
    for (int i : top_stations) {
      int dist_from_start = pos_mod(i - start, n);
      dist = max(dist, min_dist[i] + dist_from_start);
    }
    cout << n * (max_candy - 1) + dist << " ";
  }
  return 0;
}
