#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
int ans[maxn];
int to[maxn];
int have[maxn];
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  memset(to, 0, sizeof(to));
  memset(have, 0, sizeof(have));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    have[x]++;
    if (to[x] == 0)
      to[x] = y;
    else {
      if (to[x] > x && y > x) to[x] = min(to[x], y);
      if (to[x] < x && y > x) to[x] = y;
      if (to[x] < x && y < x) to[x] = min(to[x], y);
    }
  }
  for (int i = 1; i <= n; i++)
    if (to[i] < i) to[i] += n;
  for (int i = 1; i <= n; i++) {
    int time = 0;
    for (int j = 1; j <= n; j++) {
      if (have[j]) {
        int t = (have[j] - 1) * n + (to[j] - j);
        if (j < i) t += j + n - i;
        if (j > i) t += j - i;
        time = max(time, t);
      }
    }
    ans[i] = time;
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
}
