#include <bits/stdc++.h>
using namespace std;
int mn[5010], sum[5010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) mn[i] = 2 * n;
  for (int i = 1; i <= m; i++) {
    int x, y, need;
    scanf("%d%d", &x, &y);
    if (y > x)
      need = y - x;
    else
      need = y + n - x;
    mn[x] = min(mn[x], need);
    sum[x]++;
  }
  for (int i = 1; i <= n; i++)
    if (sum[i] == 0) mn[i] = 0;
  for (int i = 1; i <= n; i++) {
    int cur = i, mx = 0;
    for (int j = 0; j <= n - 1; j++) {
      if (sum[cur]) mx = max(mx, mn[cur] + (sum[cur] - 1) * n + j);
      cur = cur % n + 1;
    }
    printf("%d ", mx);
  }
  puts("");
  return 0;
}
