TRIP - Trip

题意翻译

题目描述 爱丽丝和鲍伯想去度假,他们每个人都制定了一个参观城市的清单,该地区正好有26个城市,因此它们被编码为小写字母“a”到“z”。清单上可能重复出现某个城市。因为他们想一起旅行,他们必须走同样的路线。他们不想增加城市或改变城市顺序,所以只能从名单上删除一些城市。他们想尽可能多地参观城市。请你将他们两人的清单合成一个清单。 输入输出格式: 输入: 输入的第一行包含一个整数,表示测试用例数T(T<=10)。每个测试用例有两行:第一行是爱丽丝的列表,第二行是鲍伯的列表。每个列表包含1到80个小写字母。 输出: 输出所有符合条件的清单,数据保证至少有一种可能的次序,但不超过1000次,按字典序输出。每个测试用例后输出一个空行。 Translated by @handahao

题目描述

Alice and Bob want to go on holiday. Each of them has drawn up a list of cities to be visited in turn. A list may contain a city more than once. As they want to travel together, they have to agree upon a common route. No one wants to change the order of the cities on his list or add other cities. Therefore they have no choice but to remove some cities from the list. Of course the common route is to involve as much sight-seeing in cities 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 first line of input contains a number T <= 10 that indicates the number of test cases to follow. Each test case consists of two lines; the first line is the list of Alice, the second line is the list of Bob. Each list consists of 1 to 80 lower case letters.

输出格式


The output for each test case should contain all different trips exactly once that meet the conditions described above. There is at least one such trip, but never more than 1000 different ones. You should order the trips in lexicographic order. Print one blank line between the output of different test cases.

输入输出样例

输入样例 #1

1
abcabcaa
acbacba

输出样例 #1

ababa
abaca
abcba
acaba
acaca
acbaa
acbca