#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 10;
vector<int> vec[N];
long long t[N], ans[N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    vec[a - 1].push_back(b - 1);
  }
  for (int i = 0; i < n; i++) {
    if ((int)vec[i].size() == 0) continue;
    sort(vec[i].begin(), vec[i].end());
    int k = lower_bound(vec[i].begin(), vec[i].end(), i) - vec[i].begin();
    if (k >= (int)vec[i].size()) k = 0;
    k = vec[i][k];
    t[i] = n * ((int)vec[i].size() - 1) + ((k > i) ? (k - i) : (n - i + k));
  }
  for (int i = 0; i < n; i++) {
    int j = i + 1, x = 1;
    ans[i] = t[i];
    if (j == n) j = 0;
    while (j != i) {
      if (t[j] != 0) ans[i] = max(ans[i], t[j] + x);
      j++, x++;
      if (j == n) j = 0;
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
