#include <bits/stdc++.h>
using namespace std;
int static_init = []() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  return 0;
}();
constexpr int N = 5000;
int16_t c[N], d[N];
int main() {
  int n, m;
  cin >> n >> m;
  while (m-- > 0) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    int16_t dd = a < b ? b - a : n - (a - b);
    if (c[a] == 0)
      d[a] = dd;
    else
      d[a] = min(d[a], dd);
    c[a]++;
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      int k = (i + j) % n;
      if (c[k] > 0) {
        ans = max(ans, j + n * (c[k] - 1) + d[k]);
      }
    }
    cout << ans << (i == n - 1 ? '\n' : ' ');
  }
  return 0;
}
