#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   const int inf = 0x3f3f3f3f;   int n, m;   int mi[maxn], cnt[maxn];   int main() {     cin >> n >> m;     memset(mi, 0x3f, sizeof(mi));     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       mi[x] = min(mi[x], (y - x + n) % n);       cnt[x]++;     }     for (int i = 1; i <= n; i++) {       long long ans = 0;       for (int j = 1; j <= n; j++)         if (cnt[j])           ans = max(ans, (j - i + n) % n + (long long)n * (cnt[j] - 1) + mi[j]);       cout << ans <<    ;     }     return 0;   }   