#include <bits/stdc++.h>
using namespace std;
struct Candy {
  Candy() = default;
  Candy(int from, int to) : m_from(from), m_to(to) {}
  int m_from;
  int m_to;
};
int Distance(const Candy &candy, int n) {
  const int d = candy.m_to - candy.m_from;
  return d < 0 ? d + n : d;
}
int Solve(int n, int start, const vector<vector<Candy>> &candies) {
  int result = 0;
  for (int step = 0; step < n; ++step) {
    const int curr = (start + step) % n;
    const auto &cs = candies[curr];
    if (cs.empty()) continue;
    result =
        max<int>(result, step + n * (cs.size() - 1) + Distance(cs.front(), n));
  }
  return result;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<vector<Candy>> candies(n);
  for (int i = 0; i < m; ++i) {
    int from, to;
    scanf("%d%d", &from, &to);
    --from, --to;
    candies[from].emplace_back(from, to);
  }
  for (auto &cs : candies) {
    sort(cs.begin(), cs.end(), [&](const Candy &lhs, const Candy &rhs) {
      return Distance(lhs, n) < Distance(rhs, n);
    });
  }
  for (int i = 0; i < n; ++i) {
    if (i != 0) printf(" ");
    printf("%d", Solve(n, i, candies));
  }
  printf("\n");
  return 0;
}
