import re;
#from itertools import *
s = list([int(n) for n in re.findall(r"\-?\d+", input())])
print(s)
t = list([int(n) for n in re.findall(r"\-?\d+", input())])
print(t)
ans = []
for i in t:
    while i in s:
        ans.append(i)
        s.remove(i)
s.sort()
for i in s:
    ans.append(i)
print(ans)
c857dd8d309bb381e252c3a4b5c2af4f773960a7
<mask token>

<mask token>
print(s)
<mask token>
print(t)
<mask token>
for i in t:
    while i in s:
        ans.append(i)
        s.remove(i)
s.sort()
for i in s:
    ans.append(i)
print(ans)

<mask token>
s = list([int(n) for n in re.findall('\\-?\\d+', input())])
print(s)
t = list([int(n) for n in re.findall('\\-?\\d+', input())])
print(t)
ans = []
for i in t:
    while i in s:
        ans.append(i)
        s.remove(i)
s.sort()
for i in s:
    ans.append(i)
print(ans)

import re
s = list([int(n) for n in re.findall('\\-?\\d+', input())])
print(s)
t = list([int(n) for n in re.findall('\\-?\\d+', input())])
print(t)
ans = []
for i in t:
    while i in s:
        ans.append(i)
        s.remove(i)
s.sort()
for i in s:
    ans.append(i)
print(ans)

import re;
#from itertools import *
s = list([int(n) for n in re.findall(r"\-?\d+", input())])
print(s)
t = list([int(n) for n in re.findall(r"\-?\d+", input())])
print(t)
ans = []
for i in t:
    while i in s:
        ans.append(i)
        s.remove(i)
s.sort()
for i in s:
    ans.append(i)
print(ans)