#include <bits/stdc++.h>
using namespace std;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
const int mxn = 5005;
int N, M;
int cnt[mxn], to[mxn], mx;
inline int dis(int a, int b) {
  if (b >= a)
    return b - a;
  else
    return N - a + b;
}
void init() {
  int a, b;
  N = getint();
  M = getint();
  while (M--) {
    a = getint();
    b = getint();
    if (cnt[a] == 0 || dis(a, b) < dis(a, to[a])) to[a] = b;
    ++cnt[a];
    if (cnt[a] > mx) mx = cnt[a];
  }
}
void sol() {
  vector<int> ans(N), arr;
  for (int i = 1; i <= N; ++i)
    if (cnt[i] + 1 >= mx) arr.push_back(i);
  for (int i = 1; i <= N; ++i)
    for (int j : arr)
      ans[i - 1] =
          max(ans[i - 1], dis(i, j) + (cnt[j] - 1) * N + dis(j, to[j]));
  for (int i : ans) cout << i << " ";
  cout << endl;
}
int main() {
  init();
  sol();
}
