#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> Mindis(n, 0x7fffffff), sz(n);
  int Maxszid = 0;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    sz[a]++;
    if (sz[a] > sz[Maxszid]) Maxszid = a;
    int dis;
    if (a < b)
      dis = b - a;
    else
      dis = n - a + b;
    Mindis[a] = min(Mindis[a], dis);
  }
  vector<int> sa(n);
  int count = 0;
  for (int i = 0; i < n; i++)
    if (sz[i] == sz[Maxszid]) sa[i] = 1, count++;
  for (int i = 0; i < n; i++) {
    int ans = (sz[Maxszid] - 1) * n, vis = 0, p = i, D = 0;
    while (1) {
      if (sa[p]) vis++, D = max(D, Mindis[p]);
      if (vis == count) break;
      ans++;
      D--;
      p++;
      if (p == n) p = 0;
    }
    ans += D;
    if (sz[Maxszid] - 1 >= 1) {
      p = i, D = 0;
      int tmpans = (sz[Maxszid] - 2) * n;
      for (int i = 0; i < n; i++) {
        if (sz[(i + p) % n] == sz[Maxszid] - 1) D = max(D, Mindis[(i + p) % n]);
        tmpans++;
        D--;
      }
      if (D >= 0) tmpans += D;
      ans = max(ans, tmpans);
    }
    cout << ans << " ";
  }
}
