Fuzzy Logic

 

It has been the goal of many computer enthusiasts to create a truly artificially intelligent computer. However, this will never be possible using current computer models because they only have the ability to see things as true or false. They cannot see things as maybe.

A new form of logic must be implemented for artificial intelligence using all three states: true, maybe, and false. All standard logic operands must be defined for these states without altering the existing operands for just true and false. The following are the new logic tables for fuzzy logic:

 

A

B

A and B

A or B

False

False

False

False

False

Maybe

False

Maybe

False

True

False

True

Maybe

False

False

Maybe

Maybe

Maybe

Maybe

Maybe

Maybe

True

Maybe

True

True

False

False

True

True

Maybe

Maybe

True

True

True

True

True

 

Your job is to implement this new logic in a program. You will get a fuzzy logic statement, such as:

 

        T|F&M|M=

 

The statement, when read from left to right, produces:

 

        T|F = True or False = True

               T&M = True and Maybe = Maybe

               M|M = Maybe or Maybe = Maybe

 

So, the statementís complete answer is Maybe. Take note of the shorthand for True, Maybe, False, And, and Or. Also, notice that each statement is read from left to right, with no blank spaces in the statement. The first two operands are processed, then the answer is processed with the next operand over and over until the statement is complete.

Your output will be the final answer for each statement. You should number the output lines (as shown in the Sample Output). You will know how many lines of input there are from the single integer at the beginning of the input file.

View - Sample Data File