#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> v1, v2;
long long n;
map<pair<long long, long long>, long long> mp1, mp2;
long long dist(long long st, long long en) {
  if (en == 0) return LLONG_MAX;
  if (en >= st) return en - st;
  return n + en - st;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long m;
    cin >> n >> m;
    vector<long long> count(n + 1, 0);
    map<long long, long long> mp;
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      count[a]++;
      if (mp.find(a) == mp.end())
        mp[a] = b;
      else {
        if (dist(a, b) < dist(a, mp[a])) {
          mp[a] = b;
        }
      }
    }
    long long ans = 0;
    long long r = *max_element(count.begin(), count.end());
    ans = (r - 1) * n;
    for (long long i = 1; i <= n; i++) {
      ans = (r - 1) * n;
      long long pos = i, ind = i;
      for (long long j = 1; j < n; j++) {
        if (pos + 1 <= n)
          pos++;
        else
          pos = 1;
        if (count[pos] == r) ind = pos;
      }
      ans += dist(i, ind);
      long long ma1 = 0;
      pos = i;
      while (1) {
        if (dist(pos, mp[pos]) > dist(pos, ind) && count[pos] == r &&
            mp[pos] != 0 && ind != 0) {
          if (dist(ind, mp[pos]) > ma1 && mp[pos] != 0)
            ma1 = dist(ind, mp[pos]);
        }
        if (pos == ind) break;
        if (pos + 1 <= n)
          pos++;
        else
          pos = 1;
      }
      long long ind1 = ind;
      if (r > 1) {
        for (long long j = 1; j <= n; j++) {
          if (count[j] == (r - 1) && dist(i, mp[j]) > dist(i, ind) + ma1 &&
              dist(j, mp[j]) > dist(j, i) && i != j) {
            ind1 = mp[j];
            ma1 = dist(ind, ind1);
          }
        }
      }
      if (dist(ind, ind1) > ma1) ma1 = dist(ind, ind1);
      ans += ma1;
      cout << ans << " ";
    }
  }
}
