// 129 #include using namespace std; vector ans; int stk[25], tot, n, cnt; void dfs(int now) { if (cnt >= 20) return; if (now > n) { cnt++; for (auto x : ans) cout << x; for (int i = tot - 1; i >= 0; i--) cout << stk[i]; puts(""); return; } if (tot) { ans.push_back(stk[--tot]); dfs(now); stk[tot++] = ans.back(); ans.pop_back(); } stk[tot++] = now; dfs(now + 1); tot--; } int main() { cin >> n; dfs(1); return 0; }