<gh_stars>0
ns, hs = input(), input()

for n in ns.split(', '):
    while n in hs:
        hs = hs.replace(n, '*'*len(n))

print(hs)

ns, hs = input(), input()

for n in ns.split(', '):
    while n in hs:
        hs = hs.replace(n, '*'*len(n))

print(hs)