Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.
In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an arbitrary sequence of these operations with arbitrary constants from 0 to 1023. When the program is run, all operations are applied (in the given order) to the argument and in the end the result integer is returned.
Petya wrote a program in this language, but it turned out to be too long. Write a program in CALPAS that does the same thing as the Petya's program, and consists of no more than 5 lines. Your program should return the same integer as Petya's program for all arguments from 0 to 1023.
## Input
The first line contains an integer _n_ (1 ≤ _n_ ≤ 5·105) — the number of lines.
Next _n_ lines contain commands. A command consists of a character that represents the operation ("_&_", "_|_" or "_^_" for AND, OR or XOR respectively), and the constant _x__i_ 0 ≤ _x__i_ ≤ 1023.
## Output
Output an integer _k_ (0 ≤ _k_ ≤ 5) — the length of your program.
Next _k_ lines must contain commands in the same format as in the input.
[samples]
## Note
You can read about bitwise operations in [https://en.wikipedia.org/wiki/Bitwise_operation](https://en.wikipedia.org/wiki/Bitwise_operation).
Second sample:
Let _x_ be an input of the Petya's program. It's output is ((_x_&1)&3)&5 = _x_&(1&3&5) = _x_&1. So these two programs always give the same outputs.
**Definitions**
Let $ n \in \mathbb{Z} $ be the number of commands in Petya’s program.
Let $ C = \{(op_i, x_i) \mid i \in \{1, \dots, n\}\} $ be the sequence of commands, where $ op_i \in \{\&, |, \oplus\} $ and $ x_i \in \{0, 1, \dots, 1023\} $.
Let $ f: \{0, 1, \dots, 1023\} \to \{0, 1, \dots, 1023\} $ be the function computed by Petya’s program:
$$ f(x) = op_n(x_n, op_{n-1}(x_{n-1}, \dots op_1(x_1, x) \dots )) $$
**Constraints**
1. $ 1 \leq n \leq 5 \cdot 10^5 $
2. $ 0 \leq x_i \leq 1023 $ for all $ i $
**Objective**
Find a program with $ k \leq 5 $ commands $ \{(op'_j, x'_j) \mid j \in \{1, \dots, k\}\} $ such that for all $ x \in \{0, 1, \dots, 1023\} $:
$$ f(x) = op'_k(x'_k, op'_{k-1}(x'_{k-1}, \dots op'_1(x'_1, x) \dots )) $$
Moreover, since all operations are bitwise and constants are 10-bit, the function $ f $ is equivalent to:
$$ f(x) = (x \mathbin{\text{op}_1} x_1) \mathbin{\text{op}_2} x_2 \mathbin{\text{op}_3} \dots \mathbin{\text{op}_n} x_n $$
and due to the linearity and idempotence properties of bitwise operations, $ f(x) $ can be rewritten as:
$$ f(x) = (x \& A) | (B) \oplus (C) $$
for some constants $ A, B, C \in \{0, 1, \dots, 1023\} $, computable by evaluating $ f $ on three basis inputs: $ x = 0 $, $ x = 1023 $, and $ x = 1 \ll i $ for each bit $ i \in \{0, \dots, 9\} $.
We can compress any sequence of AND, OR, XOR operations into at most 3 operations:
$$ f(x) = ((x \& A) \mid B) \oplus C $$
and further reduce to at most 5 operations if needed, but optimally to 3.
Thus, compute constants $ A, B, C $ such that:
- $ A $: bits preserved (AND mask)
- $ B $: bits forced to 1 (OR mask)
- $ C $: bits flipped (XOR mask)
Then output the minimal sequence of up to 5 operations that implements $ f(x) = ((x \& A) | B) \oplus C $, using at most one of each operation type, in optimal order.
**Output**
Find $ k \in \{0, 1, 2, 3, 4, 5\} $ and $ k $ commands minimizing the program length while preserving $ f(x) $ for all $ x \in [0, 1023] $.