#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  long long int n, m;
  cin >> n >> m;
  vector<list<long long int> > G(n + 1);
  long long int i, j;
  for (i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    G[x].push_back(y);
  }
  long long int time[n + 1];
  for (i = 1; i <= n; i++) {
    if (G[i].size() == 0)
      time[i] = 0;
    else {
      long long int from = i, mi = 1e9;
      for (auto it = G[i].begin(); it != G[i].end(); it++) {
        long long int to = (*it);
        if (to >= from) {
          mi = min(mi, to - from);
        } else {
          mi = min(mi, n - from + to);
        }
      }
      time[i] = (G[i].size() - 1) * (n) + mi;
    }
  }
  for (i = 1; i <= n; i++) {
    long long int ans = time[i];
    j = i + 1;
    while (j != i) {
      if (j == n + 1) j = 1;
      if (j == i) break;
      if (time[j] == 0) {
        j++;
        continue;
      }
      if (j > i) {
        long long int tem = j - i + time[j];
        ans = max(ans, tem);
      } else {
        long long int tem = n - i + j + time[j];
        ans = max(ans, tem);
      }
      j++;
    }
    cout << ans << " ";
  }
  cout << "\n";
  return 0;
}
