#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1e9 + 7;
constexpr int INF = 2e9;
constexpr long long INFL = 8e18;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n);
  for (int i = 0; i < m; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    --ai, --bi;
    a[ai].push_back(bi);
  }
  vector<int> c(n);
  for (int i = 0; i < n; ++i) {
    for (int &j : a[i]) {
      if (j < i) {
        j += n;
      }
    }
    sort(a[i].begin(), a[i].end());
    if (a[i].empty()) {
      c[i] = -1;
    } else {
      c[i] = (a[i].size() - 1) * n + (a[i].front() - i);
    }
  }
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    int ansi = 0;
    for (int j = i; j < i + n; ++j) {
      if (c[j % n] != -1) {
        ansi = max(ansi, (j - i) + c[j % n]);
      }
    }
    ans[i] = ansi;
  }
  for (int x : ans) {
    cout << x << ' ';
  }
  cout << endl;
  return 0;
}
