#include using namespace std; const int MAX_N = 5e5; int can_div[MAX_N] = {}; struct init_prime { init_prime() { can_div[1] = -1; for (int i = 2; i < MAX_N; i++) { if (can_div[i] != 0) continue; for (int j = i + i; j < MAX_N; j += i) can_div[j] = i; } } } init_prime; inline bool is_prime(int n) { if (n <= 1) return false; return !can_div[n]; } void factorization(int n, unordered_map &res) { if (n <= 1) return; if (!can_div[n]) { ++res[n]; return; } ++res[can_div[n]]; factorization(n / can_div[n], res); } int main() { int n; cin >> n; vector odd(n + 1); vector> v(n + 1); for (int i = 1; i <= n; i++) { unordered_map F; factorization(i, F); int q = 1; for (auto [p, e] : F) { if (e & 1) q *= p; } odd[i] = q; v[q].push_back(i); } vector ans(n); for (int i = 1; i <= n; i++) { ans[i - 1] = v[odd[i]].back(); v[odd[i]].pop_back(); } for (int i = 0; i < n; i++) cout << ans[i] << (i + 1 == n ? "\n" : " "); }