#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 2e4 + 7;
int dist(int a, int b, int n) {
  if (b >= a)
    return b - a;
  else
    return n + b - a;
}
int mindis[N];
int ant[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(mindis, 0x3f, sizeof(mindis));
  memset(ant, 0, sizeof(ant));
  for (int i = 1; i < (m + 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    ant[a]++;
    mindis[a] = min(mindis[a], dist(a, b, n));
  }
  for (int i = 1; i < (n + 1); ++i) {
    int ans = 0;
    for (int j = 1; j < (n + 1); ++j) {
      if (ant[j] == 0) continue;
      ans = max(ans, n * (ant[j] - 1) + mindis[j] + dist(i, j, n));
    }
    printf("%d ", ans);
  }
  return 0;
}
