https://www.acmicpc.net/problem/10974
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
int32_t main() {
fastio;
int n; cin >> n;
vector<int> v(n);
iota(v.begin(), v.end(),1);
do{
for(auto& c : v) cout << c << ' ';
cout << "\n";
}
while(next_permutation(v.begin(), v.end()));
return 0;
}