#include <bits/stdc++.h>
using namespace std;
int t[300010], r[300010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    r[x] = t[x] ? min(r[x], (y + n - x) % n) : (y + n - x) % n;
    ++t[x];
  }
  for (int i = (1); i <= (n); ++i) {
    int ans = 0;
    for (int j = (1); j <= (n); ++j)
      if (t[j]) {
        ans = max(ans, (j + n - i) % n + (t[j] - 1) * n + r[j]);
      }
    printf("%d ", ans);
  }
}
