LCC/Moose '19 Contest 4 J3 - King Evan

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

In WLMOJistan, there is a royal king who's name is Evan. King Evan has a very long list of servants, whom he ranks from 1 to N (1 \leq N \leq 10^5). Sometimes, he becomes displeased with a servant and decides to switch the rank of that servant to another position.

The servants of King Evan want to keep track of King Evan's list, and who is at which position. Every time it updates, they want to know which two servants changed ranks.

Can you help them with this?

Input Specification

The first line of input will consist of one integer, N, the number of servants.

The next line of input will be King Evan's list before he changed it and will consist of N space separated alphanumeric strings, a_i in this list indicates that the ith servant's name is a_i. 1 \leq |a_i| \leq 100. It is guaranteed that each name will be unique and the sum of all name lengths is at most 5 000 000.

The next line of input will be King Evan's list after he changed it. It will be in the same format as the previous line.

Output Specification

The output will consist of two space separated strings, the names of the two servants who switched ranks, in lexicographical order by ASCII value.

If it is impossible to make the second list by only swapping exactly two servants, output Death is inevitable.

Sample Input

3
Larry Theodore Steven
Steven Theodore Larry

Sample Output

Larry Steven

Comments

There are no comments at the moment.