#include <bits/stdc++.h>
using namespace std;
template <typename tp>
inline void read(tp& x) {
  x = 0;
  char tmp;
  bool key = 0;
  for (tmp = getchar(); !isdigit(tmp); tmp = getchar()) key = (tmp == '-');
  for (; isdigit(tmp); tmp = getchar()) x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
const int N = 5010, M = 20010, INF = 0x3f3f3f3f;
vector<int> vec[N];
int n, m, tms[N], mn[N];
int askdis(int x, int y) {
  if (y - x >= 0) return y - x;
  return y - x + n;
}
int main() {
  read(n), read(m);
  for (int i = 1, a, b; i <= m; ++i) {
    read(a), read(b);
    vec[a].push_back(b);
  }
  for (int i = (1); i <= (n); ++i) {
    tms[i] = (int)vec[i].size();
    if (!tms[i])
      mn[i] = 0;
    else {
      mn[i] = INF;
      for (int j = 0; j < (int)vec[i].size(); ++j)
        mn[i] = min(mn[i], askdis(i, vec[i][j]));
    }
  }
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = 1; j <= n; ++j)
      if (tms[j]) ans = max(ans, askdis(i, j) + (tms[j] - 1) * n + mn[j]);
    printf("%d ", ans);
  }
  puts("");
  return 0;
}
