#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-5;
const double PI = atan(1.0) * 4.0;
const long long mod = 1e9 + 7;
int T = 1, n, m, x, y;
int dis[5005], v[5005];
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  while (T--) {
    cin >> n >> m;
    memset(dis, INF, sizeof(dis));
    for (int i = 1; i <= m; i++) {
      cin >> x >> y;
      dis[x] = min(dis[x], (y - x + n) % n);
      v[x]++;
    }
    for (int i = 1; i <= n; i++) {
      int ans = 0;
      for (int j = 1; j <= n; j++) {
        if (!v[j]) continue;
        ans = max(ans, (j - i + n) % n + (v[j] - 1) * n + dis[j]);
      }
      printf("%d ", ans);
    }
  }
  return 0;
}
