#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(vector<T> s) {
  for (T i : s) cout << i << " ";
  cout << endl;
}
long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }
const int mod = 1e9 + 7;
long long power(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
const int maxn = 1e5 + 7;
int cnt(int i, int j, int n) {
  if (i < j) return j - i;
  return j + n - i;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> maxi(n, n);
  vector<int> summa(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    maxi[a - 1] = min(cnt(a - 1, b - 1, n), maxi[a - 1]);
    summa[a - 1]++;
  }
  for (int i = 0; i < n; i++) {
    int answer = 0;
    for (int j = 0; j < n; j++) {
      int k = (i + j) % n;
      if (summa[k] > 0) answer = max(answer, j + (summa[k] - 1) * n + maxi[k]);
    }
    cout << answer << " ";
  }
  cout << endl;
  return 0;
}
