#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
deque<int> vec[N];
long long last[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    vec[u].push_back(v);
  }
  for (int i = 1; i <= n; ++i) {
    last[i] = 1e9;
    for (auto a : vec[i]) {
      if (a > i) {
        last[i] = min(last[i], 1ll * a - 1ll * i);
      } else {
        last[i] = min(last[i], 1ll * n - 1ll * (i - a));
      }
    }
    if (vec[i].size()) {
      last[i] += 1ll * ((int)vec[i].size() - 1) * n;
    }
  }
  for (int i = 1; i <= n; ++i) {
    long long maxi = 0;
    for (int j = 1; j <= n; ++j) {
      if (vec[j].empty()) continue;
      long long x = j - i;
      if (x < 0) x += n;
      x += last[j];
      maxi = max(maxi, x);
    }
    printf("%lld ", maxi);
  }
  return 0;
}
