PROBLEM C: MOLECULES -------------------- In this abstraction from a molecular engineering problem, we are given four, equal-length, molecular chains that are to form a super molecule. The super molecule is formed as an interlocking rectangular arrangement of the four given molecular chain strands. The interlocking feature is the sharing of a common molecule between pairs of chains. For example, suppose we have the following four molecular chains of length 12: OIMDIHEIAFNL CHJDBJMHPJKD LCBJOJGIEKBO KAINLHLOLBEJ These can be placed in the interlocking arrangements: O L O C I C I H M B M J CHJDBJMHPJKD D D I O LCBJOJGIEKBO H J -OR- H J E G E M I I KAINLHLOLBEJ A E A P F K F J KAINLHLOLBEJ N K L O L D In this problem, we have some constraints on the arrangements being sought: 1. If a chain is placed in one of the horizontal slots, it must keep the same left-to-right orientation it had originally, i.e. it can not be flipped around. 2. If a chain is placed in one of the vertical slots, the original left-to-right orientation must match the top-to-bottom orientation. 3. The enclosed rectangular region at the center of the super molecule must have as large an area as possible, and the area cannot be zero. The area is measured as the count of vacant character positions within the enclosed rectangle of the super molecule. The area counts of the two super molecules iluustrated above are 30 and 4. 4. None of the four original chains can have either its first ot its last element as part of the interlocking-rectangle boundary. In other words, all chains must "stick out" from all sides of the rectangle. Input ----- The input consists of a series of data sets. Each data set consists of four molecular chains of 12 fixed elements each. These 12 elements are given as contiguous capital letters. The molecule designators within the chains will be restricted to the sixteen letters, A...P. A line containing a single Q character designates the end of the input. Output ------ A line with a single integer must be outputted for each input data set. This integer is the maximum area enclosed by any legitimate arrangement of the four chains. Use the output value 0 (zero) to indicate that no legitimate super molecule could be formed for a given data set. Sample Input ------------ CDBADCBBEFEF DACCBADAFEAB EFBDCAADBDCD ABCDABCDABCD BBBABBBABBBB CCACCCACCCCC DDDDADDADDDD EEAEEAEEEEEE BBBBBBBBBBBB CCCCCCCCCCCC DDDDDDDDDDDD EEEEEEEEEEEE Q Sample Output ------------- 48 6 0