#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int count[6000];
  int dis[6000];
  memset(count, 0, sizeof(count));
  memset(dis, 0, sizeof(dis));
  for (int i = 0; i < m; i++) {
    int s, e;
    scanf("%d%d", &s, &e);
    if (count[s] == 0) {
      dis[s] = (e - s + n) % n;
    } else {
      dis[s] = min(dis[s], (e - s + n) % n);
    }
    count[s]++;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      ans = max(ans, dis[j] + (count[j] - 1) * n + (j - i + n) % n);
    }
    printf("%d ", ans);
  }
  return 0;
}
