Consider an all-play-all tournament, in which each team (or player) will meet every other participant exactly once, in turns. For instance, if we have football teams, we will have concurrent matches in different days. In the end, we aim for each team to have competed against all the other teams. Additionally, for fairness, we want every team to play times at home and times away, or times at home and times away. A similar situation would arise in a chess tournament, where we require all the players to have as many white pieces as black pieces (plus minus one).
Given the names of the teams (or players), can you schedule all the matches?
Input consists of several cases, each with , followed by different names made up of only lowercase letters. Assume , and that is even.
Print lines for each case. The first lines should have matches separated by spaces. A match is a pair of names separated by a dash, where the first team plays at home and the second team plays away. End each case with a line with 10 asterisks. Since there is more than one solution, print any one. Follow strictly the format of the sample output.
Input
2 barca sampdoria 4 karpov kasparov fischer spassky 6 a b c d e f
Output
sampdoria-barca ********** spassky-karpov kasparov-fischer karpov-fischer spassky-kasparov kasparov-karpov fischer-spassky ********** e-c f-b d-a b-a c-f d-e c-d f-a b-e f-d b-c a-e e-f a-c d-b **********