#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
struct debug {
  template <class T>
  debug& operator<<(const T&) {
    return *this;
  }
};
using ll = long long;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
  }
  auto Dist = [&](int x, int y) {
    int d = y - x;
    if (d < 0) {
      d += n;
    }
    return d;
  };
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end(),
         [&](int x, int y) { return Dist(i, x) < Dist(i, y); });
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (g[j].empty()) {
        continue;
      }
      int cur = Dist(i, j);
      cur += n * ((int)g[j].size() - 1);
      cur += Dist(j, g[j][0]);
      max_self(ans, cur);
    }
    cout << ans << " ";
  }
  cout << "\n";
}
