#include <bits/stdc++.h>
using namespace std;
int n, m;
inline int dis(int x, int y) {
  if (y - x >= 0)
    return y - x;
  else
    return n - x + y;
}
struct arr {
  int x, y;
  inline bool operator<(const arr& a) const {
    return x < a.x || x == a.x && dis(x, y) > dis(a.x, a.y);
  }
} a[100000];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
  }
  sort(a + 1, a + m + 1);
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= m; j++) {
      int k = j;
      while (k < m && a[k + 1].x == a[k].x) k++;
      ans = max(ans, dis(i, a[k].x) + dis(a[k].x, a[k].y) + (k - j) * n);
      j = k;
    }
    printf("%d ", ans);
  }
  return 0;
}
