시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB177675.000%

문제

Alice and Bob want to go on holiday. Each of them has planned a route, which is a list of cities to be visited in a 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. None wants to change the order of the cities on his or her route or add other cities. Therefore they have no choice but to remove some cities from the route. Of course the common route should be as long as possible.

There are exactly 26 cities in the region. Therefore they are encoded on the lists as lower case letters from ’a’ to ’z’.

입력

The standard input 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 lower case letters with no spaces in between.

출력

The standard output 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 ones. The order of the routes in the output file doesn’t matter.

예제 입력 1

abcabcaa
acbacba

예제 출력 1

ababa
abaca
abcba
acbca
acaba
acaca
acbaa