#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const int MAX = 2e9 + 7;
const long long MOD = 1e9 + 7;
long long cnt[5100];
int near[5100];
void solve(int qq) {
  long long n, m;
  cin >> n >> m;
  for (int i = 0; i < 5100; i++) {
    near[i] = MAX;
  }
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    cnt[from]++;
    int k = to - from;
    if (k < 0) k = n + k;
    near[from] = min(near[from], k);
  }
  for (int i = 1; i <= n; i++) {
    long long ans = 0;
    for (int j = 1; j <= n; j++) {
      long long temp = j - i;
      if (temp < 0) temp = n + temp;
      temp += max(cnt[j] - 1, 0ll) * n + near[j];
      if (temp >= MAX) continue;
      ans = max(ans, temp);
    }
    cout << ans << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; i++) {
    solve(i);
  }
  return 0;
}
