#include <bits/stdc++.h>
using namespace std;
const int inv = 1000000000;
const int minv = -inv;
const int max_n = 5000 + 5;
int n, m;
int ct[max_n];
int mn[max_n];
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  fill(ct, ct + n, 0);
  fill(mn, mn + n, n);
  int a, b;
  for (int z = 0; z < m; ++z) {
    scanf("%d", &a);
    scanf("%d", &b);
    --a;
    --b;
    ++ct[a];
    mn[a] = min(mn[a], (b + n - a) % n);
  }
  for (int s = 0; s < n; ++s) {
    int res = 0;
    for (int i = 0; i < n; ++i)
      if (ct[i] > 0) res = max(res, n * (ct[i] - 1) + (i + n - s) % n + mn[i]);
    printf("%d ", res);
  }
  printf("\n");
  return 0;
}
