#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> v(n, INF);
  vector<int> cnt(n);
  for (int i = 0; i < m; ++i) {
    int f, s;
    cin >> s >> f;
    int d = f - s;
    if (d < 0) {
      d += n;
    }
    --s;
    cnt[s]++;
    v[s] = min(v[s], d);
  }
  int ma = *max_element(cnt.begin(), cnt.end());
  for (int i = 0; i < n; ++i) {
    int ans = n * (ma - 1);
    int d = 0;
    for (int j = 0; j < n; ++j) {
      if (cnt[j] < ma - 1) {
        continue;
      }
      int curj = j - i;
      if (curj < 0) {
        curj += n;
      }
      int pos = curj + v[j];
      if (cnt[j] == ma - 1 && cnt[j] > 0) {
        if (pos >= n) {
          d = max(d, pos - n);
        }
      } else if (cnt[j] == ma) {
        d = max(d, pos);
      }
    }
    ans += d;
    cout << ans << " ";
  }
  return 0;
}
