#include <bits/stdc++.h>
using namespace std;
long long n, m;
int dist(int a, int b) {
  if (a < b)
    return b - a;
  else
    return n - a + b;
}
int choose(vector<long long> &station, int cur) {
  auto it = lower_bound(station.begin(), station.end(), cur);
  if (it == station.end()) {
    it = station.begin();
  }
  return dist(cur, *it);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  vector<vector<long long> > stations(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    stations[a].push_back(b);
  }
  for (int i = 0; i < n; ++i) sort(stations[i].begin(), stations[i].end());
  vector<long long> mn(n);
  for (int i = 0; i < n; ++i) {
    if (stations[i].size() == 0)
      mn[i] = -1;
    else
      mn[i] = choose(stations[i], i);
  }
  for (int i = 0; i < n; ++i) {
    long long c = i, loop = 0, ans = 0, mx = 0;
    for (int j = 0; j < n; ++j, ++c) {
      if (c == n) c = 0;
      if (loop > stations[c].size())
        continue;
      else if (loop == stations[c].size()) {
        mx = max(mx, mn[c] - dist(c, i));
      } else if (stations[c].size() > 0 && loop == stations[c].size() - 1) {
        mx = max(mx, mn[c] + j);
      } else if (stations[c].size() > 0) {
        ans += n * (stations[c].size() - loop - 1);
        loop = stations[c].size() - 1;
        mx = mn[c] + j;
      }
    }
    ans += mx;
    cout << ans << " ";
  }
  cout << "\n";
  return 0;
}
