#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 1, mod = 1e9 + 7, inf = 1e9;
int n, m, mini[maxn], a[maxn], b[maxn], deg[maxn];
vector<int> candy[maxn];
vector<pair<int, int> > o;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    mini[i] = inf;
  }
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    deg[a[i]]++;
    int tmp;
    if (a[i] < b[i]) {
      tmp = b[i] - a[i];
    } else {
      tmp = b[i] + n - a[i];
    }
    mini[a[i]] = min(mini[a[i]], tmp);
  }
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (deg[j] == 0) {
        continue;
      }
      int w = (deg[j] - 1) * n + mini[j];
      if (i <= j) {
        w += j - i;
      } else {
        w += n - i + j;
      }
      cnt = max(cnt, w);
    }
    cout << cnt << " ";
  }
  return 0;
}
