#include <bits/stdc++.h>
using namespace std;
const int N = 5050;
int n, m, a, b, ans;
int num[N], dis[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) dis[i] = 2 * n;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &a, &b);
    num[a]++;
    dis[a] = min(dis[a], (b - a + n) % n);
  }
  for (int i = 1; i <= n; ++i) {
    ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (num[j]) ans = max(ans, (j - i + n) % n + (num[j] - 1) * n + dis[j]);
    }
    printf("%d ", ans);
  }
  puts("");
}
