#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> count(n, 0), mini(n, -1), cost(n, 0);
  for (int i = 0; i < m; i++) {
    int temp1, temp2;
    cin >> temp1 >> temp2;
    count[temp1 - 1]++;
    if (count[temp1 - 1] == 1)
      mini[temp1 - 1] = (temp2 - temp1 + n) % n;
    else
      mini[temp1 - 1] = min(mini[temp1 - 1], (temp2 - temp1 + n) % n);
  }
  for (int i = 0; i < n; i++) {
    if (count[i] != 0) {
      cost[i] = n * (count[i] - 1) + mini[i];
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (count[j] != 0) {
        int temp = (j - i + n) % n + cost[j];
        ans = max(temp, ans);
      }
    }
    cout << ans << ' ';
  }
}
