#include <bits/stdc++.h>
int main() {
  std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
  int n, m;
  std::cin >> n >> m;
  std::vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    std::cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  std::vector<std::vector<int>> to(n);
  for (int i = 0; i < m; i++) {
    to[a[i]].push_back(b[i]);
  }
  std::vector<int> num(n), end(n);
  for (int i = 0; i < n; i++) {
    num[i] = int(to[i].size());
    if (num[i] == 0) {
      end[i] = 0;
    } else {
      end[i] = n;
      for (int nxt : to[i]) {
        if (nxt > i) {
          end[i] = std::min(end[i], nxt - i);
        } else {
          end[i] = std::min(end[i], nxt + n - i);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < n; j++) {
      if (!num[j]) continue;
      int cur = n * (num[j] - 1);
      if (i <= j) {
        cur += j - i;
      } else {
        cur += n + j - i;
      }
      cur += end[j];
      ans = std::max(ans, cur);
    }
    std::cout << ans << ' ';
  }
  std::cout << '\n';
}
