#include <bits/stdc++.h>
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::vector<int> > sweets(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    if (a != b) {
      sweets[a - 1].push_back(b - 1);
    }
  }
  for (int i = 0; i < n; i++) {
    std::sort(sweets[i].begin(), sweets[i].end());
  }
  for (int i = 0; i < n; i++) {
    int time = 0;
    for (int j = 0; j < n; j++) {
      int id = (i + j) % n;
      if (!sweets[id].size()) {
        continue;
      }
      auto it = std::upper_bound(sweets[id].begin(), sweets[id].end(), id);
      if (it == sweets[id].end()) it = sweets[id].begin();
      int cur_time = j + (sweets[id].size() - 1) * n + (n + *it - id) % n;
      time = std::max(time, cur_time);
    }
    std::cout << time << ' ';
  }
  std::cout << std::endl;
  return 0;
}
