#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  int id;
  node() {}
  node(int x, int id) : x(x), id(id) {}
  bool operator<(const node &oth) const { return x > oth.x; }
};
int n, ax1, ay1, ax2, ay2;
int a[500005], b[500005];
int mi[5005], c[5005];
int d[5005][5005], m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) mi[i] = n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (j >= i)
        d[i][j] = j - i;
      else
        d[i][j] = n + j - i;
  int x;
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    c[a[i]]++;
    x = d[a[i]][b[i]];
    if (x < mi[a[i]]) mi[a[i]] = x;
  }
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 1; j <= n; j++) {
      if (c[j] == 0) continue;
      x = (c[j] - 1) * n + mi[j] + d[i][j];
      if (x > tmp) tmp = x;
    }
    printf("%d%c", tmp, i == n ? '\n' : ' ');
  }
}
