CEOI 2003 - Contest Environment

Menu

Main

Tasks:
pearls
register
trip

Logout

Task description

Print view - submit program

Trip

Input Filetrip.in
Output File[none]
Source Codetrip.pas/.c/.cpp
Time Limit7 seconds per test case
Memory Limit16 MBytes

Alice and Bob want to go on a holiday. Each of them has planned a route, which is a list of cities to visit in the given order. A route may contain a city more than once.

As they want to travel together, they have to agree on a common route. Neither wants to change the order of the cities on his or her route or add new cities. Therefore they have no choice but to remove some cities from their routes. Of course the common route should be as long as possible.

There are exactly 26 cities in the region. Therefore they are encoded in the lists as lowercase letters from 'a' to 'z'.

Input

The input file trip.in consists of two lines; the first line is Alice's list, the second line is Bob's list. Each list consists of 1 to 80 lowercase letters with no spaces in between.

Output

The output file trip.out should contain all routes that meet the conditions described above, but no route should be listed more than once. Each route should be printed on a separate line. There is at least one such non-empty route, but never more than 1000 different routes. The order of the routes in the output file doesn't matter.

Example

trip.intrip.out
abcabcaa
acbacba
ababa
abaca
abcba
acbca
acaba
acaca
acbaa

Translations

Croatian
Czech
Dutch
German
Polish
Slovakian