#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[5001];
int n, m, a, b, k, mx, cnt, tc;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    arr[i].second = n;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    k = b - a;
    if (k < 0) k += n;
    arr[a].second = min(arr[a].second, k);
    arr[a].first++;
  }
  for (int i = 1; i <= n; i++) {
    cnt = tc = 0;
    for (int j = i; j <= n; j++) {
      tc++;
      if (arr[j].first == 0) {
        continue;
      }
      cnt = max(cnt, (arr[j].first - 1) * n + arr[j].second + tc);
    }
    for (int j = 1; j < i; j++) {
      tc++;
      if (arr[j].first == 0) {
        continue;
      }
      cnt = max(cnt, (arr[j].first - 1) * n + arr[j].second + tc);
    }
    printf("%d ", cnt - 1);
  }
  return 0;
}
