#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> candies(n, vector<int>());
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    candies[a].push_back((b - a + n) % n);
  }
  for (int i = 0; i < n; ++i) {
    sort(candies[i].begin(), candies[i].end());
    reverse(candies[i].begin(), candies[i].end());
  }
  for (int i = 0; i < n; ++i) {
    int res = 0;
    for (int j = 0; j < n; ++j) {
      int pos = i + j;
      if (pos >= n) pos -= n;
      if (candies[pos].size() > 0)
        res = max(res,
                  j + (int)(candies[pos].size() - 1) * n + candies[pos].back());
    }
    cout << res << " ";
  }
  cout << endl;
  return 0;
}
