#include <bits/stdc++.h>
using namespace std;
const int maxn = 5500;
int n, m;
struct node {
  int x, y;
};
node sum[maxn * 5];
int dis(int x, int y) {
  if (x <= y)
    return abs(y - x);
  else
    return abs(n - x) + y;
}
bool cmp(node n1, node n2) {
  if (n1.x == n2.x)
    return dis(n1.x, n1.y) > dis(n2.x, n2.y);
  else
    return n1.x < n2.x;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &sum[i].x, &sum[i].y);
  sort(sum + 1, sum + m + 1, cmp);
  for (int i = 1; i <= n; i++) {
    int ans = 0, t = 0;
    for (int j = 1; j <= m; j++) {
      t = j;
      while (t < m && sum[t + 1].x == sum[j].x) t++;
      ans = max(ans, dis(i, sum[t].x) + dis(sum[t].x, sum[t].y) + (t - j) * n);
      j = t;
    }
    printf("%d ", ans);
  }
  return 0;
}
