#include <bits/stdc++.h>
using namespace std;
long long n, m, k, j, o, l, r;
long long a[500001], t[500001];
long long b[5001];
bool fl1 = 0, fl2 = 0;
long long dist(long long x, long long y) {
  if (x <= y)
    return y - x;
  else
    return n - x + y;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    if (t[x] == 0)
      b[x] = y;
    else if (dist(x, b[x]) > dist(x, y))
      b[x] = y;
    t[x]++;
  }
  for (int i = 0; i < n; i++) {
    long long ans = 0;
    for (int j = 0; j < n; j++)
      if (t[j]) {
        ans = max(dist(i, j) + n * (t[j] - 1) + dist(j, b[j]), ans);
      }
    cout << ans << " ";
  }
  return 0;
}
