#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int inf = 100000000;
int n, m;
int cnt[5010];
int near[5010];
int mini[5010];
void prep() {
  for (int i = 1; i <= int(n); i++) near[i] = inf;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  prep();
  for (int i = 0; i < int(m); i++) {
    int x, y;
    cin >> x >> y;
    cnt[x]++;
    int dist = y - x;
    if (dist < 0) dist += n;
    near[x] = min(near[x], dist);
  }
  for (int i = 1; i <= int(n); i++) {
    for (int j = 1; j <= int(n); j++) {
      if (cnt[j] == 0)
        mini[j] = 0;
      else
        mini[j] = ((j - i + n) % n) + (cnt[j] - 1) * n + near[j];
    }
    cout << *max_element(mini + 1, mini + n + 1) << " ";
  }
}
