#include <bits/stdc++.h>
using namespace std;
int candy[5005];
int num[5005];
bool vis[5005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int s, t;
    scanf("%d%d", &s, &t);
    num[s]++;
    if (num[s] == 1)
      candy[s] = (t - s + n) % n;
    else
      candy[s] = min(candy[s], (t - s + n) % n);
  }
  for (int st = 1; st <= n; st++) {
    int res = 0;
    memset(vis, 0, sizeof vis);
    for (int i = st;; i++) {
      if (i > n) i = 1;
      if (vis[i]) break;
      vis[i] = 1;
      if (num[i] == 0) continue;
      res = max(res, (num[i] - 1) * n + candy[i] + (i - st + n) % n);
    }
    printf("%d ", res);
  }
}
