#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
template <class T>
inline void umin(T &x, T y) {
  x = x < y ? x : y;
}
template <class T>
inline void umax(T &x, T y) {
  x = x > y ? x : y;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 20200;
int a[N], n, m;
vector<int> b[N];
int main() {
  read(n);
  read(m);
  while (m--) {
    int x, y;
    read(x);
    read(y);
    int d = y >= x ? y - x : y - x + n;
    b[x].push_back(d);
  }
  for (register int i = (1); i <= (n); i++) sort(b[i].begin(), b[i].end());
  for (register int i = (1); i <= (n); i++)
    if (((int)b[i].size()))
      a[i] = b[i][0] + n * (((int)b[i].size()) - 1);
    else
      a[i] = -1e9;
  for (register int i = (1); i <= (n); i++) {
    int res = 0;
    for (int j = i, t = 0; t < n; t++, j = j + 1 <= n ? j + 1 : 1)
      umax(res, t + a[j]);
    printf("%d ", res);
  }
  return 0;
}
