#include <bits/stdc++.h>
using namespace std;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcount(s);
}
template <class T>
inline T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long n, m, nex[5004];
vector<long long> ke[20004];
long long kc(long long i, long long j) {
  if (j >= i) return j - i;
  return n + j - i;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1, _b = m; i <= _b; i++) {
    long long u, v;
    cin >> u >> v;
    ke[u].push_back(v);
  }
  for (long long i = 1, _b = n; i <= _b; i++) {
    nex[i] = 1e18;
    if (!ke[i].size())
      nex[i] = 0;
    else {
      for (auto x : ke[i]) nex[i] = min(nex[i], kc(i, x));
      nex[i] += n * (ke[i].size() - 1);
    }
  }
  for (long long i = 1, _b = n; i <= _b; i++) {
    long long res = 0;
    for (long long j = 1, _b = n; j <= _b; j++) {
      if (ke[j].size()) res = max(res, kc(i, j) + nex[j]);
    }
    cout << res << " ";
  }
  return 0;
}
