Many words offend somebody, and removing them from a text is easy to automate no matter where they appear. The offending ones are usually called four-letter words, mostly because they are, but this program looks at every run of four letters, whether the run is a whole word or sits inside a longer one.
Which words count as offensive depends on the listener. Some people find work unsettling, if not outright offensive, so the list is given as input instead of being fixed. The words on the list are themselves too offensive to spell out, so each one is written as its first and last letter only.
For example, if ct is on the list, then cantered becomes c**tered, because cant is a run of four letters that starts with c and ends with t.
The first part of the input is the list of words. Each line holds one word, written as exactly two lowercase letters: its first letter and its last letter. The list holds at most 20 words and ends with a line containing two # characters.
The rest of the input is the paragraph to sanitise. Each line of the paragraph is at most 60 characters long, and no word is split across a line break. The paragraph ends with a line containing a single # character.
Print the sanitised paragraph. The closing # line is not part of it.
Sanitise each line on its own, scanning it from left to right. At position i, look at the four characters starting there. If all four are letters (A to Z or a to z, so no whitespace, no punctuation mark, no other character) and the first one followed by the fourth one is a word on the list, replace the two middle characters with ** and resume the scan at position i+4. Otherwise move to position i+1. The two middle characters may be uppercase or lowercase.
The match is case sensitive, so an uppercase letter never matches a lowercase letter on the list. Every other character, tabs and line breaks included, keeps its value and its position.