beecrowd | 3160

Friends

By Jones Mendonça de Souza, IFSP BR Brazil

Timelimit: 1

Luiggy likes to make friends and is always expanding his list of friends on the social network ListBook. The ListBook allows you to include your new friends in your friendship list and also refer them to other friends in your network, all dynamically, with no limits on friends in your network. As Luiggy is your friend, he asked you to create a program to make his life easier with this task. For this, Luiggy had the following idea:

  1. The program should read Luiggy's current list of friends;
  2. The program should read Luiggy's new list of friends;
  3. The program should read the name of the current friend who will receive the new list as an indication of friends.

Input

You should read Luiggy L's list of friends in a single line, containing only the first name and separated by a blank space. In the second line, the new list of friends N must be informed. In the last line, the name of friend S from the network that you want to indicate also this new list of friends N. If you do not want to indicate the new list of friends to anyone, just type in last line the word “no”.

Output

Your program should display Luiggy's new updated friends list. If there is an indication of a friend on the list, the new friends must be inserted before the name of the indicated friend. If there is no indication, the new names must be inserted at the end of Luiggy's list of friends.

Input Samples Output Samples

Jones Pedro Carlos Lucas

Juca Valdineia Jovander

Carlos

Jones Pedro Juca Valdineia Jovander Carlos Lucas

Jones Pedro Carlos Lucas

Juca Valdineia Jovander

nao

Jones Pedro Carlos Lucas Juca Valdineia Jovander