#P450. 【例82.2】 座次问题

【例82.2】 座次问题

Description

In Little A's school, after solving the registration problem for the city competition, the teacher is now facing another challenge. There are NN students participating in the competition, and the teacher needs to arrange their seats. There are many possible arrangements, and the teacher wants to know what all the possible arrangements look like and how many different arrangements there are.
Please design a program to help the teacher. Output each possible arrangement of names, one arrangement per line, with names in each arrangement sorted according to their registration (input) order.

Input Format

The first line contains NN;
The next NN lines contain NN names.
Due to the limited capacity of Little A's school, NN is less than or equal to 10.

Output Format

Output each possible arrangement of names, one arrangement per line, with names in each arrangement sorted according to their registration (input) order.

Sample

3
xiaowang
xiaoA
xiaoli
xiaowang xiaoA xiaoli
xiaowang xiaoli xiaoA
xiaoA xiaowang xiaoli
xiaoA xiaoli xiaowang
xiaoli xiaowang xiaoA
xiaoli xiaoA xiaowang