#include <bits/stdc++.h>
using namespace std;
void FastIO() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
}
int main() {
  FastIO();
  int n, m;
  cin >> n >> m;
  vector<vector<int>> st(n, vector<int>());
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    st[a].push_back((b - a + n) % n);
  }
  std::multiset<int> all;
  for (int i = 0; i < n; ++i) {
    sort(st[i].begin(), st[i].end(), [](int a, int b) { return a > b; });
    for (int j = 0; j < st[i].size(); ++j) {
      all.insert(i + n * j + st[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << *all.rbegin() - i << " ";
    for (int j = 0; j < st[i].size(); ++j) {
      auto was = i + n * j + st[i][j];
      all.erase(all.find(was));
      all.insert(was + n);
    }
  }
  return 0;
}
