#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
long long POW(long long a, long long b, long long MMM) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
long long n, m, M;
vector<vector<long long> > arr(5500);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, j;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    long long t, tt;
    cin >> t >> tt;
    arr[t].push_back(t > tt ? (n - (t - tt)) : tt - t);
    M = max(M, (long long)arr[t].size());
  }
  for (i = 1; i <= n; i++) {
    sort(arr[i].begin(), arr[i].end());
  }
  for (i = 1; i <= n; i++) {
    long long mmm = 0;
    for (j = 1; j <= n; j++) {
      if (arr[j].size()) {
        long long tr = j >= i ? (j - i) : (n - (i - j));
        mmm = max(mmm, tr + n * ((long long)arr[j].size() - 1) + arr[j][0]);
      }
    }
    cout << mmm << ' ';
  }
  return 0;
}
