#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, m, a[N], b[N];
vector<int> station[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  int mx = 0;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    station[a].push_back(b);
    mx = max(mx, (int)station[a].size());
  }
  for (int i = 1; i <= n; i++) {
    int res = (mx - 1) * n;
    int cnt = 0;
    for (int j = i; j <= i + n - 1; j++) {
      int now = j;
      if (j > n) now -= n;
      if (station[now].size() < mx) {
        if (station[now].size() == mx - 1 && mx != 1) {
          int mn_dist = 1e9;
          for (auto& x : station[now])
            mn_dist = min(mn_dist, (x - now + n) % n);
          cnt = max(cnt, (j - i + mn_dist) - n);
        }
        continue;
      }
      int mn_dist = 1e9;
      for (auto& x : station[now]) mn_dist = min(mn_dist, (x - now + n) % n);
      cnt = max(cnt, j - i + mn_dist);
    }
    cout << res + cnt << ' ';
  }
}
