#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int N = 5e3 + 5, M = 2e4 + 5;
vector<vector<int>> v(N);
vector<int> t(N, INT_MAX), ans(N, 0);
int n, m;
int dis(int i, int j) {
  if (i <= j)
    return j - i;
  else
    return n - i + j;
}
void solve() {
  for (int i = 1; i <= n; i++) {
    for (auto &j : v[i]) {
      t[i] = min(t[i], dis(i, j));
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 0;
    for (int j = 1; j <= n; j++) {
      if (v[j].size() == 0) continue;
      ans = max(ans, dis(i, j) + n * (int(v[j].size()) - 1) + t[j]);
    }
    cout << ans << ' ';
  }
  cout << "\n";
}
int main() {
  fast();
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  solve();
}
