#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(n + 1);
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    if (a > b)
      v[a].push_back(n - a + b);
    else
      v[a].push_back(b - a);
  }
  for (long long i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (long long i = 1; i <= n; i++) {
    long long x = i;
    long long m = i;
    long long ma = 0;
    for (long long j = 0; j < n; j++) {
      if (x > n) x = 1;
      long long y = v[x].size();
      if (y > 0) {
        long long t = (y - 1) * n + v[x][0] + m - i;
        if (t > ma) ma = t;
      }
      x++;
      m++;
    }
    cout << ma << " ";
  }
}
