#include <bits/stdc++.h>
using namespace std;
const long long int N = 10005;
const long long int mod = 119 << 23 | 1;
long long int n, m;
map<long long int, vector<long long int>> mp;
long long int c[N];
vector<long long int> v;
long long int extra[N];
long long int power(long long int a, long long int b, long long int c) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % c;
    a = (a * a) % c;
    b = b >> 1;
  }
  return ans;
}
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    if (b > a)
      mp[a].push_back(b);
    else
      mp[a].push_back(n + b);
    c[a]++;
  }
  for (long long int i = 1; i <= n; i++) {
    sort(mp[i].begin(), mp[i].end());
  }
  long long int temp = 0;
  for (long long int i = 1; i <= n; i++) {
    temp = max(temp, c[i]);
  }
  long long int ans = (temp - 1) * n;
  for (long long int i = 1; i <= n; i++) {
    if (temp == c[i]) {
      extra[i] = mp[i][0] - i;
    }
  }
  for (long long int i = 1; i <= n; i++) {
    long long int lol = 0;
    for (long long int j = i; j <= n; j++) {
      if (temp == c[j])
        lol = max(extra[j] + (j - i), lol);
      else if (c[j] > 0 and temp == c[j] + 1 and
               (mp[j][0] % n > i and mp[j][0] % n < j)) {
        lol = max(lol, (mp[j][0] - i + n) % n);
      }
    }
    for (long long int j = 1; j < i; j++) {
      if (temp == c[j])
        lol = max(extra[j] + (j - i + n), lol);
      else if (c[j] > 0 and temp == c[j] + 1 and
               (mp[j][0] % n > i or mp[j][0] % n < j)) {
        lol = max(lol, (mp[j][0] - i + n) % n);
      }
    }
    cout << ans + lol << " ";
  }
  return 0;
}
