You are given boolean variables that can be either or .
Let us define an environment , an assignment of either or to all variables (like ).
Also, let us define an expression , a string that can be generated by the following grammar:
For example, is an expression.
Each expression has a value in an environment. (for example, expression has value in environment but it has value in environment ).
You are given environments and their expected value (the value that the expressions should have in them), find an expression that satisfies environments as much as possible, and uses operations (and, or, not, xor) as least as possible, in other words for each of tests your score will be:
Let be your expression.
Let be the number of environments like that .
Input format
The first line contains two integers and separated by space.
Each of the following lines contains space-separated and , is a string containing and s of length , the character in is value of in .
Output format
Print a single line of the expression.
Constraints
In 7 tests:
In 3 tests:
In other tests:
Notes
The expression should not contain any space.
Print instead of .
Print following characters instead of operations:
& for .
| for .
! for .
^ for .
For example, should be printed as .
You can use at most operations.
The expression's length can be at most .
Sample Input
3 2
101 1
011 0
111 1
Sample Output
((0&(!1))|(0&1))
Time Limit: 7
Memory Limit: 256
Source Limit:
Explanation
Also experssion (should be printed 0) satisfies all enviroments.