#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k = 0;
  cin >> n >> m;
  v.assign(n, make_pair(1 << 30, 0));
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].second++;
    v[a].first = min(v[a].first, (b - a + n) % n);
    k = max(k, v[a].second);
  }
  for (int i = 0; i < n; i++) {
    long long ans = (k - 1) * n;
    long long tmp = 0;
    for (int j = 0; j < n; j++) {
      if (v[j].second == k) {
        long long x = (long long)(j - i + n) % n + v[j].first;
        tmp = max(tmp, x);
      } else if (i != j && k > 1 && v[j].second == k - 1) {
        long long x = (long long)v[j].first - (long long)(i - j + n) % n;
        tmp = max(tmp, x);
      }
    }
    cout << ans + tmp << " ";
  }
  cout << endl;
  return 0;
}
