#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 100, M = 4 * N;
const long long mod = 998244353;
int n, m, a[M], b[M], at[N], st[N];
int get(int a, int b) {
  if (a <= b)
    return b - a;
  else
    return n - (a - b);
}
int main(int argc, const char* argv[]) {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) st[i] = INT_MAX / 2;
  for (int i = 0; i < m; ++i) {
    scanf("%d %d", a + i, b + i);
    ++at[a[i]];
    st[a[i]] = min(st[a[i]], get(a[i], b[i]));
  }
  int ans = -1;
  vector<int> ret(n + 1, INT_MAX / 2);
  for (int i = 0; i < n; ++i) {
    if (at[i + 1] > ans) {
      ans = at[i + 1];
    }
  }
  for (int i = 1; i <= n; ++i) {
    ret[i] = 0;
    for (int j = 1; j <= n; ++j)
      if (at[j]) {
        ret[i] = max(ret[i], n * (at[j] - 1) + get(i, j) + st[j]);
      }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d ", ret[i]);
  }
  return 0;
}
