#include <bits/stdc++.h>
using namespace std;
const long long M = 5000 + 10;
long long n, m;
pair<long long, long long> to[M];
int main() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) to[i].second = 0x3f3f3f3f, to[i].first = 0;
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    a--, b--;
    to[a].first++, to[a].second = min(to[a].second, (b + n - a) % n);
  }
  for (long long i = 0; i < n; i++) {
    long long ans = 0;
    for (long long j = 0; j < n; j++) {
      if (to[(i + j) % n].first == 0) continue;
      long long an = to[(i + j) % n].first * n - n + j + to[(i + j) % n].second;
      ans = max(ans, an);
    }
    cout << ans << ' ';
  }
  return 0;
}
