## Round and round we go

Statement

## Goal

Kids are passing a ball among themselves while standing in a big circle. Whenever someone gets the ball they always pass it to the person mentioned in the puzzle input so that the ball travels in a big loop that visits everyone.Now they want to change things up and

**reverse the direction of the ball**. Help them figure out who to pass the ball to now.

Input

**LIne 1:**An integer

`N`for the number of kids playing.

**Next**Rule description for passing the ball in the form of

`N`lines:name1passes the ball toname2

Output

**Rule description for passing the ball in the opposite direction in the same format as and order as input i.e.**

`N`lines:**the line should start with the same name as the corresponding line of input**.

Constraints

1 ≤

Name constraints:

* All names are unique.

* Each name is composed of one or more words (e.g. first name, middle name, last name, title,...).

* No part of a name will start with a lower case letter.

* Full name will be at most 300 characters.

`N`≤ 20Name constraints:

* All names are unique.

* Each name is composed of one or more words (e.g. first name, middle name, last name, title,...).

* No part of a name will start with a lower case letter.

* Full name will be at most 300 characters.

Example

Input

4 Michelangelo passes the ball to Raphael Donatello passes the ball to Leonardo Leonardo passes the ball to Michelangelo Raphael passes the ball to Donatello

Output

Michelangelo passes the ball to Leonardo Donatello passes the ball to Raphael Leonardo passes the ball to Donatello Raphael passes the ball to Michelangelo

Game modes

Fastest, Shortest, Reverse

Test cases

Ninjas Test

Input

4
Michelangelo passes the ball to Raphael
Donatello passes the ball to Leonardo
Leonardo passes the ball to Michelangelo
Raphael passes the ball to Donatello

Output

Michelangelo passes the ball to Leonardo
Donatello passes the ball to Raphael
Leonardo passes the ball to Donatello
Raphael passes the ball to Michelangelo

Ninjas Validator

Input

4
Donatello passes the ball to Raphael
Michelangelo passes the ball to Leonardo
Raphael passes the ball to Michelangelo
Leonardo passes the ball to Donatello

Output

Donatello passes the ball to Leonardo
Michelangelo passes the ball to Raphael
Raphael passes the ball to Donatello
Leonardo passes the ball to Michelangelo

No friends Test

Input

1
Mr. Lonely passes the ball to Mr. Lonely

Output

Mr. Lonely passes the ball to Mr. Lonely

No friends Validator

Input

1
Lonely Boy Jr. passes the ball to Lonely Boy Jr.

Output

Lonely Boy Jr. passes the ball to Lonely Boy Jr.

Two friends Test

Input

2
Alice passes the ball to Bob
Bob passes the ball to Alice

Output

Alice passes the ball to Bob
Bob passes the ball to Alice

Two friends Validator

Input

2
Mickey passes the ball to Minnie
Minnie passes the ball to Mickey

Output

Mickey passes the ball to Minnie
Minnie passes the ball to Mickey

Three friends Test

Input

3
Alice passes the ball to Bob
Charlie passes the ball to Alice
Bob passes the ball to Charlie

Output

Alice passes the ball to Charlie
Charlie passes the ball to Bob
Bob passes the ball to Alice

Three friends Validator

Input

3
Alice passes the ball to Charlie
Bob passes the ball to Alice
Charlie passes the ball to Bob

Output

Alice passes the ball to Bob
Bob passes the ball to Charlie
Charlie passes the ball to Alice

Four friends Test

Input

4
C-3PO passes the ball to Chewbacca
Han Solo passes the ball to Darth Vader
Darth Vader passes the ball to C-3PO
Chewbacca passes the ball to Han Solo

Output

C-3PO passes the ball to Darth Vader
Han Solo passes the ball to Chewbacca
Darth Vader passes the ball to Han Solo
Chewbacca passes the ball to C-3PO

Four friends Validator

Input

4
C-3PO passes the ball to Darth Vader
Chewbacca passes the ball to C-3PO
Darth Vader passes the ball to Han Solo
Han Solo passes the ball to Chewbacca

Output

C-3PO passes the ball to Chewbacca
Chewbacca passes the ball to Han Solo
Darth Vader passes the ball to C-3PO
Han Solo passes the ball to Darth Vader

Long name Test

Input

6
Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains passes the ball to Jon Snow
Arya Stark passes the ball to Sansa Stark
Robert Baratheon passes the ball to Robert Arryn
Jon Snow passes the ball to Arya Stark
Robert Arryn passes the ball to Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains
Sansa Stark passes the ball to Robert Baratheon

Output

Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains passes the ball to Robert Arryn
Arya Stark passes the ball to Jon Snow
Robert Baratheon passes the ball to Sansa Stark
Jon Snow passes the ball to Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains
Robert Arryn passes the ball to Robert Baratheon
Sansa Stark passes the ball to Arya Stark

Long name Validator

Input

6
Jon Snow passes the ball to Arya Stark
Arya Stark passes the ball to Robert Baratheon
Robert Arryn passes the ball to Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains
Sansa Stark passes the ball to Robert Arryn
Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains passes the ball to Jon Snow
Robert Baratheon passes the ball to Sansa Stark

Output

Jon Snow passes the ball to Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains
Arya Stark passes the ball to Jon Snow
Robert Arryn passes the ball to Sansa Stark
Sansa Stark passes the ball to Robert Baratheon
Daenerys Stormborn Of House Targaryen, The First Of Her Name, Queen Of The Andals And The First Men, Protector Of The Seven Kingdoms, The Mother Of Dragons, The Khaleesi Of The Great Grass Sea, The Unburnt, The Breaker Of Chains passes the ball to Robert Arryn
Robert Baratheon passes the ball to Arya Stark

Weird characters Test

Input

5
André 3000 passes the ball to John F. Kennedy Jr.
John F. Kennedy Jr. passes the ball to Robert'); DROP TABLE Students;--
X Æ A-12 Musk passes the ball to Conan O'Brian
Conan O'Brian passes the ball to André 3000
Robert'); DROP TABLE Students;-- passes the ball to X Æ A-12 Musk

Output

André 3000 passes the ball to Conan O'Brian
John F. Kennedy Jr. passes the ball to André 3000
X Æ A-12 Musk passes the ball to Robert'); DROP TABLE Students;--
Conan O'Brian passes the ball to X Æ A-12 Musk
Robert'); DROP TABLE Students;-- passes the ball to John F. Kennedy Jr.

Weird characters Validator

Input

5
Robert'); DROP TABLE Students;-- passes the ball to John F. Kennedy Jr.
André 3000 passes the ball to X Æ A-12 Musk
Conan O'Brian passes the ball to André 3000
X Æ A-12 Musk passes the ball to Robert'); DROP TABLE Students;--
John F. Kennedy Jr. passes the ball to Conan O'Brian

Output

Robert'); DROP TABLE Students;-- passes the ball to X Æ A-12 Musk
André 3000 passes the ball to Conan O'Brian
Conan O'Brian passes the ball to John F. Kennedy Jr.
X Æ A-12 Musk passes the ball to André 3000
John F. Kennedy Jr. passes the ball to Robert'); DROP TABLE Students;--

Huge random Test

Input

20
P THe7 Z passes the ball to N' P E
S<fCUr~"&%r)mc R<L" passes the ball to P THe7 Z
N' P E passes the ball to CO,O{,QQx V|J#
Wtf"cw5: passes the ball to Y
B;3?#ap/JWk) NA passes the ball to WS Is5ShR?$J
CO,O{,QQx V|J# passes the ball to S/ Y0T,qNJ[+K$w"f
Pa; passes the ball to G`-
S/ Y0T,qNJ[+K$w"f passes the ball to Wtf"cw5:
E4kbm passes the ball to FJYB/}7y598$gM3r4m-
G`- passes the ball to EGpMl+:8;B0`85VBWx
H Ue SM!$ passes the ball to S<fCUr~"&%r)mc R<L"
X Hs!o passes the ball to E4kbm
Y|~Elx6w,*q HFx> passes the ball to Pa;
YE2Oq;!e@m passes the ball to Z;c
Z;c passes the ball to H Ue SM!$
S YfN*-+nGN)GVwS2i passes the ball to YE2Oq;!e@m
FJYB/}7y598$gM3r4m- passes the ball to S YfN*-+nGN)GVwS2i
EGpMl+:8;B0`85VBWx passes the ball to X Hs!o
Y passes the ball to B;3?#ap/JWk) NA
WS Is5ShR?$J passes the ball to Y|~Elx6w,*q HFx>

Output

P THe7 Z passes the ball to S<fCUr~"&%r)mc R<L"
S<fCUr~"&%r)mc R<L" passes the ball to H Ue SM!$
N' P E passes the ball to P THe7 Z
Wtf"cw5: passes the ball to S/ Y0T,qNJ[+K$w"f
B;3?#ap/JWk) NA passes the ball to Y
CO,O{,QQx V|J# passes the ball to N' P E
Pa; passes the ball to Y|~Elx6w,*q HFx>
S/ Y0T,qNJ[+K$w"f passes the ball to CO,O{,QQx V|J#
E4kbm passes the ball to X Hs!o
G`- passes the ball to Pa;
H Ue SM!$ passes the ball to Z;c
X Hs!o passes the ball to EGpMl+:8;B0`85VBWx
Y|~Elx6w,*q HFx> passes the ball to WS Is5ShR?$J
YE2Oq;!e@m passes the ball to S YfN*-+nGN)GVwS2i
Z;c passes the ball to YE2Oq;!e@m
S YfN*-+nGN)GVwS2i passes the ball to FJYB/}7y598$gM3r4m-
FJYB/}7y598$gM3r4m- passes the ball to E4kbm
EGpMl+:8;B0`85VBWx passes the ball to G`-
Y passes the ball to Wtf"cw5:
WS Is5ShR?$J passes the ball to B;3?#ap/JWk) NA

Huge random Validator

Input

20
Y% Xw7 XTp passes the ball to H%
NSSraGyRR passes the ball to EHif+^E3`>B^G
U9A;'1?QX passes the ball to MQ[qN]
Nf(q,{S`fO LA' passes the ball to Y% Xw7 XTp
ZR I5 UL"i(W CznWC passes the ball to I]% YSmy
L*va?;d passes the ball to P8 U]mWf
Zk;%P@<`ykh passes the ball to ZR I5 UL"i(W CznWC
A A95 passes the ball to L*va?;d
P8 U]mWf passes the ball to J[n!5G9 JcmZOd
P%JNEVEY JZ KXEE passes the ball to V#aR4y`
Z{ N T passes the ball to U<
V#aR4y` passes the ball to T$Qg JR Q3hIVhasa-H
QyYg.PcgnOI{Q_rk{J[ passes the ball to Nf(q,{S`fO LA'
H% passes the ball to U9A;'1?QX
MQ[qN] passes the ball to Z{ N T
EHif+^E3`>B^G passes the ball to A A95
U< passes the ball to NSSraGyRR
T$Qg JR Q3hIVhasa-H passes the ball to Zk;%P@<`ykh
J[n!5G9 JcmZOd passes the ball to P%JNEVEY JZ KXEE
I]% YSmy passes the ball to QyYg.PcgnOI{Q_rk{J[

Output

Y% Xw7 XTp passes the ball to Nf(q,{S`fO LA'
NSSraGyRR passes the ball to U<
U9A;'1?QX passes the ball to H%
Nf(q,{S`fO LA' passes the ball to QyYg.PcgnOI{Q_rk{J[
ZR I5 UL"i(W CznWC passes the ball to Zk;%P@<`ykh
L*va?;d passes the ball to A A95
Zk;%P@<`ykh passes the ball to T$Qg JR Q3hIVhasa-H
A A95 passes the ball to EHif+^E3`>B^G
P8 U]mWf passes the ball to L*va?;d
P%JNEVEY JZ KXEE passes the ball to J[n!5G9 JcmZOd
Z{ N T passes the ball to MQ[qN]
V#aR4y` passes the ball to P%JNEVEY JZ KXEE
QyYg.PcgnOI{Q_rk{J[ passes the ball to I]% YSmy
H% passes the ball to Y% Xw7 XTp
MQ[qN] passes the ball to U9A;'1?QX
EHif+^E3`>B^G passes the ball to NSSraGyRR
U< passes the ball to Z{ N T
T$Qg JR Q3hIVhasa-H passes the ball to V#aR4y`
J[n!5G9 JcmZOd passes the ball to P8 U]mWf
I]% YSmy passes the ball to ZR I5 UL"i(W CznWC

Solution language

Solution

Stub generator input

Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!

JOIN US ON DISCORD Online Participants