#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const long long LINF = numeric_limits<long long>::max();
const long long mod = 1000 * 1000 * 1000 + 7;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    --a[i], --b[i];
  }
  vector<int> c(n, 0);
  for (int i = 0; i < m; ++i) {
    ++c[a[i]];
  }
  vector<int> d(n, n);
  for (int i = 0; i < m; ++i) {
    int l = b[i] - a[i];
    if (l < 0) l += n;
    d[a[i]] = min(d[a[i]], l);
  }
  for (int i = 0; i < n; ++i)
    if (d[i] == n) d[i] = 0;
  vector<int> res(n);
  for (int i = 0; i < n; ++i) {
    res[i] = (c[i] - 1) * n + d[i];
  }
  for (int i = 0; i < n; ++i) {
    int ans = res[i];
    for (int j = 1; j < n; ++j) {
      int l = i + j;
      if (l >= n) l -= n;
      ans = max(ans, res[l] + j);
    }
    cout << ans << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();
  return 0;
}
