#include <bits/stdc++.h>
using namespace std;
const int N = 5010, M = 20010;
int n, m;
int min_stat[N];
long long cnt_stat[N];
long long ans;
long long dist(int a, int b) {
  if (a <= b) {
    return (long long)(b - a);
  } else {
    return (long long)(n - a + b);
  }
}
int it[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    cnt_stat[a]++;
    if (cnt_stat[a] == 1 || dist(a, min_stat[a]) > dist(a, b)) {
      min_stat[a] = b;
    }
  }
  for (int i = 1; i <= n; ++i) {
    ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (cnt_stat[j] > 0)
        ans = max(ans, ((long long)cnt_stat[j] - 1) * (long long)n +
                           dist(i, j) + dist(j, min_stat[j]));
    }
    cout << ans << ' ';
  }
}
