#include <bits/stdc++.h>
using ll = long long;
const int INF = 1e9;
int n, m;
std::vector<std::vector<int>> a;
std::vector<ll> dist;
int distance(int i, int j) {
  j -= i;
  if (j < 0) {
    j += n;
  }
  return j;
}
int main() {
  std::cin >> n >> m;
  a.resize(n);
  dist.resize(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    std::cin >> x >> y;
    a[x - 1].push_back(y - 1);
  }
  for (int i = 0; i < n; ++i) {
    if (a[i].empty()) {
      dist[i] = 0;
      continue;
    }
    int min_dist = INF;
    for (auto j : a[i]) {
      min_dist = std::min(min_dist, distance(i, j));
    }
    dist[i] = (ll)(a[i].size() - 1) * n + min_dist;
  }
  for (int i = 0; i < n; ++i) {
    ll max = 0;
    for (int j = 0; j < n; ++j) {
      if (dist[(i + j) % n] == 0) {
        continue;
      }
      max = std::max(max, j + dist[(i + j) % n]);
    }
    std::cout << max << ' ';
  }
  return 0;
}
