#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
template <typename T, typename... V>
inline void wonl(T t, V... v) {
  ww(t);
  if (sizeof...(v)) putchar(' ');
  wonl(v...);
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> graph[n + 1];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (b < a)
      b = b - a + n;
    else
      b -= a;
    graph[a].push_back(b);
  }
  for (int i = 0; i <= n; i++) {
    sort(graph[i].begin(), graph[i].end());
  }
  vector<int> minans(n);
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    if (graph[i + 1].size()) {
      minans[i] = (graph[i + 1].size() - 1) * n + graph[i + 1][0];
    } else
      minans[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (minans[(i + j) % n] > 0)
        ans[i] = max(ans[i], j + minans[(i + j) % n]);
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
