#include <bits/stdc++.h>
using namespace std;
long long modulo = 1e9 + 7;
template <class X>
void printarr(X arr[], long long n) {
  for (long long i = 0; i < n; ++i) cout << arr[i] << " ";
  cout << "\n";
}
long long fpow(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = (ans * a) % modulo;
    a = (a * a) % modulo;
    n = n >> 1;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> arr[n + 1];
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    arr[a].push_back(b);
  }
  for (long long j = 1; j < n + 1; ++j) {
    long long ans = 0;
    for (long long i = 1; i < n + 1; ++i) {
      long long diff = LLONG_MAX, min_dest = 0, cnt = 0;
      for (long long a : arr[i]) {
        long long dest = a;
        if (dest <= i) dest += n;
        ++cnt;
        if (dest - i < diff) {
          min_dest = a;
          diff = dest - i;
        }
      }
      long long time = max(0ll, (cnt - 1) * n);
      if (min_dest) {
        long long source = i, start = j;
        if (start == source) {
          if (min_dest <= start)
            time += (n + min_dest - start);
          else
            time += (min_dest - start);
        } else if (start < source) {
          if (min_dest >= start) {
            if (min_dest > source)
              time += (min_dest - start);
            else
              time += (n + min_dest - start);
          } else
            time += (n + min_dest - start);
        } else {
          if (min_dest >= start)
            time += (n + min_dest - start);
          else {
            if (min_dest <= source)
              time += (2 * n + min_dest - start);
            else
              time += (n + min_dest - start);
          }
        }
      }
      ans = max(ans, time);
    }
    cout << ans << " ";
  }
  return 0;
}
