#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  long long n, m;
  cin >> n >> m;
  vector<long long> cnt(10000, 0);
  vector<long long> mi(10000, LLONG_MAX);
  for (int i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    cnt[x]++;
    if (y > x)
      mi[x] = min(mi[x], y - x);
    else
      mi[x] = min(mi[x], n - x + y);
  }
  vector<long long> ans(10000, 0);
  for (int i = 1; i <= n; ++i) {
    if (cnt[i])
      ans[i] = n * (cnt[i] - 1) + mi[i];
    else
      ans[i] = -1;
  }
  for (int i = 1; i <= n; ++i) {
    long long p = LLONG_MIN;
    long long k = 1, j;
    if (i == n)
      j = 1;
    else
      j = i + 1;
    if (ans[i] != -1) p = max(p, ans[i]);
    while (j != i) {
      if (ans[j] != -1) p = max(p, ans[j] + k);
      k++;
      if (j == n)
        j = 1;
      else
        j++;
    }
    cout << p << " ";
  }
  cout << '\n';
}
