#include using namespace std; using ll = long long; struct Sieve { Sieve(int n) : l(n + 1, 0) { for (int i = 2; i <= n; i++) { if (!l[i]) p.push_back(l[i] = i); for (int q : p) { if (q > l[i]) break; if (int j = i * q; j <= n) l[j] = q; else break; } } } bool is_prime(int i) { return l[i] == i; } vector l, p; }; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n + 1); for (int i = 1; i <= n; i++) { a[i] = i; } Sieve si(n); for (int i = 1; i <= n; i++) { int t = i, s = 1; while (t > 1) { int l = si.l[t]; int k = 0; while (t % l == 0) t /= l, k++; if (k & 1) s *= l; } for (int j = (int)sqrt(n / s); j > 0; j--) { int r = j * j * s; if (r <= i) break; if (a[r] == r) { swap(a[i], a[r]); break; } } } for (int i = 1; i <= n; i++) { cout << a[i] << " \n"[i == n]; } return 0; }