#include <bits/stdc++.h>
using namespace std;
const int N = 5100, M = 21000;
int n, m, x, y, rd[N], a[N], w[N];
int main() {
  scanf("%d%d", &n, &m);
  memset(a, 0x3f, sizeof(a));
  for (int i = (1); i <= (m); i++)
    scanf("%d%d", &x, &y), rd[x]++, a[x] = min(a[x], (y - x + n) % n);
  for (int i = (1); i <= (n); i++)
    if (rd[i]) w[i] = (rd[i] - 1) * n + a[i];
  for (int i = (1); i <= (n); i++) {
    int ans = 0;
    for (int j = (1); j <= (n); j++)
      if (rd[j]) ans = max(ans, w[j] + (j - i + n) % n);
    printf("%d ", ans);
  }
  return 0;
}
