#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
vector<int> G[5005];
int V[5005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (y < x) y += n;
    G[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    int mi = n * 2;
    for (int j : G[i]) mi = min(mi, j);
    if (G[i].size()) {
      V[i] = (G[i].size() - 1) * n + mi - i;
    } else
      V[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    int ma = 0;
    for (int j = 1; j <= n; j++)
      if (V[j] != 0) {
        if (j < i) {
          ma = max(ma, j + n - i + V[j]);
        } else
          ma = max(ma, j - i + V[j]);
      }
    printf("%d ", ma);
  }
  return 0;
}
