SP1728 CPRMT - Common Permutation

Description

Given two strings of lowercase letters, **_a_** and **_b_**, print the longest string **_x_** of lowercase letters such that there is a permutation of **_x_** that is a subsequence of **_a_** and there is a permutation of **_x_** that is a subsequence of **_b_**.

Input Format

Input file contains several lines of input. Consecutive two lines make a set of input. That means in the input file line **1** and **2** is a set of input, line **3** and **4** is a set of input and so on. The first line of a pair contains **_a_** and the second contains **_b_**. Each string is on a separate line and consists of at most **1000** lowercase letters.

Output Format

For each set of input, output a line containing **_x_**. If several **_x_** satisfy the criteria above, choose the first one in alphabetical order.