#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  ;
  long long int t = 1;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    long long int i, j, k;
    vector<vector<pair<long long int, long long int>>> v(n + 1);
    for (i = 1; i <= m; i++) {
      cin >> j >> k;
      v[j].push_back({(k - j + n) % n, k});
    }
    for (i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
    for (i = 1; i <= n; i++) {
      long long int maxs = 0;
      for (j = 1; j <= n; j++) {
        if (v[j].size() == 0) continue;
        long long int time = (j - i + n) % n;
        time += v[j][0].first, time += (v[j].size() - 1) * n;
        maxs = max(time, maxs);
      }
      cout << maxs << " ";
    }
  }
}
