#include <bits/stdc++.h>
using namespace std;
int r, n, m, a, b, t[110], dest[110];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    int h = b - a;
    if (h < 0) h += n;
    dest[a] = min(dest[a], h);
    if (t[a] == 0) dest[a] = h;
    t[a]++;
  }
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= n; j++) {
      int h = j - i;
      if (h < 0) h += n;
      r = max(r, (t[j] - 1) * n + h + dest[j]);
    }
    printf("%d ", r);
    r = 0;
  }
  for (int j = 1; j <= n; j++) {
    int h = j;
    if (h == n) h = 0;
    r = max(r, (t[j] - 1) * n + h + dest[j]);
  }
  printf("%d\n", r);
  return 0;
}
