#include <bits/stdc++.h>
using namespace std;
int mp[5555];
int dist[5555];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (long long(i) = (0); (i) < (5555); ++i) dist[i] = 1000000000;
  long long n, m;
  cin >> n >> m;
  for (long long(i) = (0); (i) < (m); ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    mp[a]++;
    if (a > b) b += n;
    dist[a] = min(dist[a], b - a);
  }
  for (long long(i) = (0); (i) < (n); ++i) {
    long long ans = 0;
    for (long long(j) = (0); (j) < (n); ++j) {
      int now = (i + j) % n;
      if (mp[now] == 0) continue;
      ans = max(ans, j + (mp[now] - 1) * n + dist[now]);
    }
    cout << ans << endl;
  }
  return 0;
}
