1577: Removing Digits

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:3 解决:2

题目描述

You are given two Strings, number and digits. Each String contains only digits between 1 and 9, inclusive. For each occurrence of a digit in digits, you must remove a single occurrence of that digit from number. Your goal is to end up with the largest possible remaining number after all the necessary digits are removed.

输入

The input file contains several sets of dada, one line per set. Each line consists of two strings number and digits. If digits is an empty string, you will get a string of "x". Input ends with both string equaling to "0" number will contain between 1 and 50 characters, inclusive. digits will contain between 0 and n-1 characters, inclusive, where n is the number of characters in number. Each character in number and digits will be a non-zero digit (‘1‘-‘9‘). The number of occurrences of each digit in number will be greater than or equal to the number of occurrences of that digit in digits.

输出

Output the largest possible remaining number after all the necessary digits are removed, One number per line.

样例输入 复制

12345 513
67 x
112352 1123
0 0

样例输出 复制

24
67
52

提示

In Sample 3, there are two choices. We can either get a "25" or a "52". The largest is "52".