#include <bits/stdc++.h>
using namespace std;
int n, m, task[5005][5005], num[5005];
int dist[5005];
int dista(int x, int y) {
  if (y >= x) {
    return y - x;
  } else {
    return n - (x - y);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    task[x][++num[x]] = y;
  }
  for (int i = 1; i <= n; i++) {
    if (num[i] == 0) {
      dist[i] = 0;
      continue;
    }
    int shortest = 9999999;
    for (int j = 1; j <= num[i]; j++) {
      shortest = min(shortest, dista(i, task[i][j]));
    }
    dist[i] = (num[i] - 1) * n + shortest;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (num[j] == 0) {
        continue;
      }
      ans = max(ans, dista(i, j) + dist[j]);
    }
    printf("%d ", ans);
  }
  cout << endl;
}
