#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int LN = 22;
long long n, m, u, v, k, t, q, x, d, p, a, b, c, s;
vector<int> rt[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    --u, --v;
    rt[u].push_back((v - u + n) % n);
  }
  for (int i = 0; i < n; ++i) sort(rt[i].begin(), rt[i].end());
  for (int i = 0; i < n; ++i) {
    long long best =
        (rt[i].size() > 0) ? n * ((int)rt[i].size() - 1) + rt[i][0] : 0;
    for (int j = i + 1, k = 1; k < n; ++j, ++k) {
      j %= n;
      best = max(
          best, ((rt[j].size() > 0) ? n * ((int)rt[j].size() - 1) + rt[j][0] + k
                                    : 0));
    }
    cout << best << " ";
  }
  cout << endl;
}
