#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long linf = 1LL << 60;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
int n, m;
int dist(int from, int to) { return (to - from + n) % n; }
int main() {
  cin >> n >> m;
  vector<vector<int> > c(n);
  for (int i = 0; i < (int)(m); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    c[a].push_back(b);
  }
  vector<int> mi(n);
  for (int i = 0; i < (int)(n); i++) {
    if (c[i].size() == 0) {
      mi[i] = -inf;
      continue;
    }
    int t = (c[i].size() - 1) * n;
    int mini = inf;
    for (auto j : c[i]) {
      mini = min(mini, dist(i, j));
    }
    mi[i] = t + mini;
  }
  for (int i = 0; i < (int)(n); i++) {
    int ans = 0;
    for (int j = 0; j < (int)(n); j++) {
      int v = (i + j) % n;
      int tmp = j + mi[v];
      ans = max(ans, tmp);
    }
    cout << ans << " \n"[i == n - 1];
  }
  return 0;
}
