#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ll = long long;
const int INF = 1e9 + 5;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> cnt(n), small(n, INF);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    ++cnt[a];
    int dist = b - a;
    if (dist < 0) {
      dist += n;
    }
    small[a] = min(small[a], dist);
  }
  for (int start = 0; start < n; ++start) {
    int answer = 0;
    for (int a = 0; a < n; ++a) {
      if (cnt[a]) {
        int dist = a - start;
        if (dist < 0) {
          dist += n;
        }
        answer = max(answer, n * (cnt[a] - 1) + dist + small[a]);
      }
    }
    printf("%d ", answer);
  }
  puts("");
}
