#include <bits/stdc++.h>
using namespace std;
const char el = '\n';
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> numatstation(n);
  auto &c = numatstation;
  vector<int> mindistfromstation(n, n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ++numatstation[a];
    int dist = b + (n - a);
    dist %= n;
    mindistfromstation[a] = min(mindistfromstation[a], dist);
  }
  vector<long long> currdist(n, 0);
  priority_queue<pair<long long, int> > q;
  for (int i = 0; i < n; ++i) {
    if (c[i] > 0) {
      currdist[i] = (long long)i + (long long)(c[i] - 1) * n +
                    (long long)mindistfromstation[i];
      q.push({currdist[i], i});
    }
  }
  vector<long long> ret(n);
  ret[0] = (long long)q.top().first;
  for (int i = 1; i < n; ++i) {
    if (c[i - 1] > 0) {
      currdist[i - 1] += n;
      q.push({currdist[i - 1], i - 1});
    }
    while (currdist[q.top().second] != q.top().first) {
      q.pop();
    }
    int j = q.top().second;
    ret[i] = (long long)((j - i + n) % n) + (long long)(c[j] - 1) * n +
             (long long)mindistfromstation[j];
  }
  for (auto x : ret) cout << x << " ";
  cout << el;
}
