A `word cross' is formed by printing a pair of words, the first horizontally and the second vertically, so that they share a common letter. A `leading word cross' is one where the common letter is as near as possible to the beginning of the horizontal word, and, for this letter, as close as possible to the beginning of the vertical word. Thus DEFER and PREFECT would cross on the first 'E' in each word, PREFECT and DEFER would cross on the 'R'. `Double leading word crosses' use two pairs of words arranged so that the two horizontal words are on the same line and each pair forms a leading word cross.
Write a program that will read in sets of four words and form them (if possible) into double leading word crosses.