#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char zf = 1;
  char ch = getchar();
  while (ch != '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') zf = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * zf;
}
void write(long long y) {
  if (y < 0) putchar('-'), y = -y;
  if (y > 9) write(y / 10);
  putchar(y % 10 + 48);
}
void writeln(const long long y) {
  write(y);
  putchar('\n');
}
int k, m, n, x, y, z, cnt, ans;
int sum[20010], far[20010];
int main() {
  n = read();
  m = read();
  for (register int i = 1; i <= m; i++) {
    x = read();
    y = read();
    sum[x]++;
    if ((y + n - x) % n < far[x] || sum[x] == 1) far[x] = (y + n - x) % n;
  }
  for (register int i = 1; i <= n; i++) {
    int ans = 0;
    for (register int j = 1; j <= n; j++)
      ans = max(ans, (sum[j] - 1) * n + far[j] + (j + n - i) % n);
    write(ans), putchar(' ');
  }
  return 0;
}
