#include <bits/stdc++.h>
using namespace std;
long long int n, m, minDist[5007], cnt[5007];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  memset(minDist, 0x3f, sizeof(minDist));
  for (long long int i = 1; i <= m; ++i) {
    long long int a, b;
    cin >> a >> b;
    cnt[a]++;
    if (b < a)
      minDist[a] = min(minDist[a], (b + n) - a);
    else
      minDist[a] = min(minDist[a], b - a);
  }
  for (long long int i = 1; i <= n; ++i) {
    long long int ans = 0;
    for (long long int j = 1; j <= n; ++j) {
      long long int d = (j < i ? (j + n) - i : j - i);
      if (minDist[j] > n) {
        continue;
      }
      ans = max(ans, d + n * (cnt[j] - 1) + minDist[j]);
    }
    cout << ans << ' ';
  }
  return 0;
}
