#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long dist(long long x, long long y) {
  if (x <= y)
    return y - x;
  else
    return (n + 1 - x) + (y - 1);
}
int main() {
  cin >> n >> m;
  vector<long long> v[5050];
  for (int i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(dist(a, b));
  }
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
  }
  for (int start = 1; start <= n; start++) {
    long long jwb = 0;
    for (int i = 1; i <= n; i++) {
      if (v[i].empty()) continue;
      long long jum = 0;
      jum += dist(start, i);
      jum += n * (v[i].size() - 1);
      jum += v[i][0];
      jwb = max(jwb, jum);
    }
    cout << jwb << " ";
  }
  cout << endl;
}
