#include <bits/stdc++.h>
using namespace std;
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  int a, b;
  vector<int> num_candies(n, 0), min_dist(n, 0);
  int max_candies = 0;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    num_candies[a - 1]++;
    min_dist[a - 1] = min_dist[a - 1] <= 0
                          ? ((b - a + n) % n)
                          : min(min_dist[a - 1], (b - a + n) % n);
    max_candies = max(max_candies, num_candies[a - 1]);
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    int dist = 0;
    for (int j = 0; j < n; j++) {
      if (num_candies[j] == max_candies) {
        dist = max(dist, (max_candies - 1) * n + (j - i + n) % n + min_dist[j]);
      } else if (num_candies[j] == max_candies - 1) {
        dist = max(dist, (max_candies - 2) * n + (j - i + n) % n + min_dist[j]);
      }
    }
    ans.push_back(dist);
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
