#include <bits/stdc++.h>
using namespace std;
const int maxN = 5042;
int mindist[maxN], numout[maxN], n;
int dist(int a, int b) { return a <= b ? b - a : b + n - a; }
int Next(int a) { return a == n ? 1 : a + 1; }
int result(int i, int j) {
  return dist(i, j) + n * (numout[j] - 1) + mindist[j];
}
int main() {
  scanf("%d", &n);
  int m;
  scanf("%d", &m);
  for (int i = 1; i < (n + 1); i++) mindist[i] = maxN;
  while (m--) {
    int a;
    scanf("%d", &a);
    int b;
    scanf("%d", &b);
    numout[a]++;
    mindist[a] = min(mindist[a], dist(a, b));
  }
  for (int i = 1; i < (n + 1); i++) {
    int res = numout[i] == 0 ? 0 : result(i, i);
    for (int j = Next(i); j != i; j = Next(j))
      if (numout[j] != 0) res = max(res, result(i, j));
    printf("%d ", res);
  }
  printf("\n");
  return 0;
}
