k,l = map(int,input().split())
o = {int(x) for x in input().split()}
p = {int(y) for y in input().split()}
x = sorted(list(o.union(p)))
for z in x:
print(z, end=" ")
ayxsID0gbWFwKGludCxpbnB1dCgpLnNwbGl0KCkpCm8gPSB7aW50KHgpIGZvciB4IGluIGlucHV0KCkuc3BsaXQoKX0KcCA9IHtpbnQoeSkgZm9yIHkgaW4gaW5wdXQoKS5zcGxpdCgpfQp4ID0gc29ydGVkKGxpc3Qoby51bmlvbihwKSkpCmZvciB6IGluIHg6CglwcmludCh6LCBlbmQ9IiAiKQ==