#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5001;
long long sum[MAX_N];
long long near[MAX_N];
long long n, m;
vector<int> great;
long long dis(long long from, long long to) {
  if (from <= to) {
    return to - from;
  } else {
    return n - from + to;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  long long from, to;
  long long max_f = 0;
  for (int i = 1; i <= m; i++) {
    cin >> from >> to;
    sum[from]++;
    max_f = max(max_f, sum[from]);
    if (!near[from]) {
      near[from] = dis(from, to);
    } else {
      near[from] = min(near[from], dis(from, to));
    }
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0ll;
    for (int j = 1; j <= n; j++) {
      ans = max(ans, dis(i, j) + n * (sum[j] - 1) + near[j]);
    }
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}
