def readBadWords(filename: str):
    fio = open(filename, "r")
    bad_words = set()

    for line in fio:
        bad_words.add(line.strip())

    fio.close()
    return bad_words


def main():
    bad_words = readBadWords("bad_words.txt")
    
    fio = open("input.txt", "r")
    fout = open("output.txt", "w")

    for line in fio:
        for wrd in bad_words:
            line = line.replace(wrd, "*"*len(wrd))
        
        fout.write(line)
    
    fio.close()
    fout.close()

main()