408981: GYM103401 J League schedule

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. League scheduletime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

People in Kingdom Z loves football. Zyw the king of Kingdom Z wants to establish a football league in his country called Z-league.

There are $$$n$$$ teams in the Z-league and each of them has an unique team name which consists of three uppercase letters. For example, PSG, MCI, MUN are legal team names but FcB, S04, OL are not.

Now, giving you $$$n$$$($$$n$$$ is even) team names. You need to arrange a schedule for the first season of Z-league. Your schedule should meet the following conditions.

1. Each pair of teams, for example team AAA and team BBB should have exactly two matches in the season. One is "AAA vs BBB" in which team AAA plays as the home team, the other is "BBB vs AAA" in which team BBB plays as the home team.

2. Each team has at most one match per week.

3. Number of weeks the season takes should be as little as possible.

Input

There are $$$n+1$$$ lines in the input.

The first line contains an even integer $$$n (1 \leq n \leq 500)$$$ represents the number of teams in Z-league.

The next $$$n$$$ lines each contains a legal team name.

Output

There are $$$n*(n-1)$$$ lines in the output.

Each line should be the format of "home_team_name vs visiting_team_name on week $$$w$$$", where maximum value of $$$w$$$ should be as little as possible.

ExamplesInput
2
MCI
MUN
Output
MCI vs MUN on week 1
MUN vs MCI on week 2
Input
4
LIV
TOT
ARS
CHE
Output
TOT vs ARS on week 1
ARS vs TOT on week 2
LIV vs CHE on week 1
CHE vs LIV on week 2
ARS vs LIV on week 4
LIV vs ARS on week 3
TOT vs CHE on week 3
CHE vs TOT on week 4
LIV vs TOT on week 5
TOT vs LIV on week 6
ARS vs CHE on week 5
CHE vs ARS on week 6

加入题单

算法标签: