#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> cnt(300, 0);
vector<int> mindis(300, INT_MAX);
int dis(int a, int b) {
  if (b < a) {
    return n - a + b;
  }
  return b - a;
}
int main() {
  cin >> n >> m;
  int a, b;
  for (long long i = 1; i <= m; ++i) {
    cin >> a >> b;
    ++cnt[a];
    mindis[a] = min(mindis[a], dis(a, b));
  }
  for (long long i = 1; i <= n; ++i) {
    int result = 0;
    for (long long j = 1; j <= n; ++j) {
      if (cnt[j] > 0) {
        result = max(result, dis(i, j) + (cnt[j] - 1) * n + mindis[j]);
      }
    }
    cout << result << " ";
  }
  cout << endl;
  return 0;
}
