#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long nxt[5007];
vector<long long> mn[5007];
int main() {
  cin >> n >> m;
  long long mx = 0;
  for (int i = 1; i <= m; ++i) {
    long long a, b;
    cin >> a >> b;
    nxt[a]++;
    if (b < a) b += n;
    mn[a].push_back(b - a);
    mx = max(mx, nxt[a]);
  }
  for (int i = 1; i <= n; ++i) sort(mn[i].begin(), mn[i].end());
  for (int st = 1; st <= n; ++st) {
    long long res = n * (mx - 1);
    long long add = 0;
    for (int i = 1; i <= n; ++i)
      if (nxt[i] == mx) {
        long long c = i - st;
        if (c < 0) c += n;
        add = max(add, mn[i][0] + c);
        if (mx > 1) {
          add = max(add, c + mn[i][1] - n);
        }
      } else if (nxt[i] + 1 == mx && mx > 1) {
        long long c = i - st;
        if (c < 0) c += n;
        add = max(add, c + mn[i][0] - n);
      }
    cout << res + add << ' ';
  }
  return 0;
}
