#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> w(n);
  for (int i = 0; i < m; i++) {
    long long g, q;
    cin >> g >> q;
    g--, q--;
    w[g].push_back(q);
  }
  for (int i = 0; i < n; i++)
    if (!w[i].empty()) sort((w[i]).begin(), (w[i]).end());
  vector<long long> c(n);
  for (int i = 0; i < n; i++)
    if (!w[i].empty()) {
      long long bs =
          upper_bound((w[i]).begin(), (w[i]).end(), i) - w[i].begin();
      if (bs == w[i].size()) bs = 0;
      long long gl = n * (w[i].size() - 1) + (n + w[i][bs] - i) % n;
      c[i] = max(gl, c[i]);
      for (int j = 1; j < n; j++) {
        gl++;
        long long j1 = (i - j + n) % n;
        c[j1] = max(gl, c[j1]);
      }
    }
  {
    for (int qz = 0; qz < c.size(); qz++) cout << (c)[qz] << ' ';
    cout << "\n";
  };
  return 0;
}
