#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long dist(long long a, long long b) {
  long long dist = (b - a);
  if (dist < 0) dist += n;
  return dist;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  vector<long long> c(n, 0);
  vector<long long> closest(n, n + 1);
  long long MAX_C = -1;
  for (int i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    --a, --b;
    ++c[a];
    MAX_C = max(MAX_C, c[a]);
    closest[a] = min(dist(a, b), closest[a]);
  }
  for (long long start = 0; start < n; ++start) {
    long long ans = 0;
    for (long long i = 0; i < n; ++i) {
      long long curr = (start + i) % n;
      if (c[curr] > 0) {
        ans = max(ans, i + (c[curr] - 1) * n + closest[curr]);
      }
    }
    cout << (ans) << ' ';
  }
  return 0;
}
