let line = readline();
let arr = line.split('').reverse().map(x => parseInt(x));
//Set有去重功能
let list = Array.from(new Set(arr));
print(list.join(''))
let line = readline();
let arr = line.split('').reverse().map(x => parseInt(x));
//Set有去重功能
let list = Array.from(new Set(arr));
print(list.join(''))