#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, i, j, k, x, y;
  cin >> n >> m;
  vector<int> v[n + 2];
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
  }
  int a[n + 5], minn[n + 5];
  fill(minn, minn + n + 5, INT_MAX);
  for (i = 1; i <= n; i++) {
    for (j = 0; j < v[i].size(); j++) {
      int a = v[i][j];
      int t;
      if (a >= i) {
        t = a - i;
      } else {
        t = n - i + a;
      }
      minn[i] = min(minn[i], t);
    }
  }
  for (i = 1; i <= n; i++) {
    int ctr = i;
    int ans = 0;
    while (1) {
      int t = 0;
      int sz = v[ctr].size();
      if (sz != 0) {
        if (ctr >= i) {
          t = ctr - i;
        } else {
          t = n - i + ctr;
        }
        if (sz >= 1) t = t + (sz - 1) * n + minn[ctr];
        ans = max(ans, t);
      }
      ctr++;
      if (ctr == n + 1) ctr = 1;
      if (ctr == i) break;
    }
    a[i] = ans;
  }
  for (i = 1; i <= n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
  return 0;
}
