#include <bits/stdc++.h>
using namespace std;
int n, m;
int minn[5005];
int br[5005];
int dis(int poc, int kraj) {
  if (poc <= kraj) return kraj - poc;
  return kraj + n - poc;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  cin >> m;
  for (int i = 1; i <= n; i++) minn[i] = n + 10;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    minn[x] = min(minn[x], dis(x, y));
    br[x]++;
  }
  for (int i = 1; i <= n; i++) {
    int sol = 0;
    for (int j = 1; j <= n; j++) {
      if (br[j] != 0) {
        sol = max(sol, dis(i, j) + (br[j] - 1) * n + minn[j]);
      }
    }
    cout << sol << " ";
  }
  return 0;
}
