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 xi 0 ≤ xi ≤ 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.

Examples

Input

3
| 3
^ 2
| 1


Output

2
| 3
^ 2


Input

3
&amp; 1
&amp; 3
&amp; 5


Output

1
&amp; 1


Input

3
^ 1
^ 2
^ 3


Output

0

Note

You can read about bitwise operations in <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.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.BitSet;

public class C {

    private static State[] bitStates;
    private static int MAX_INDEX = 9;

    public static void main(String[] args) throws Exception {
        bitStates = new State[MAX_INDEX + 1];
        Arrays.fill(bitStates, State.DEFAULT);

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());

        for (int i=0; i<N; i++) {
            String s = br.readLine();
            String[] tokens = s.split(" ");
            char operation = tokens[0].charAt(0);
            int constant = Integer.parseInt(tokens[1]);
            Command command = new Command(operation, constant, MAX_INDEX);
            command.apply(bitStates);
        }

        // Now let us construct the final short program.
        // Everything that is set, needs to be OR-ed.
        BitSet OR = BitSet.valueOf(new long[]{0});
        OR.clear();
        for (int i=0; i<=MAX_INDEX; i++) {
            if (bitStates[i] == State.SET) {
                OR.set(i);
            }
        }
        int orConstant = 0;
        if (OR.toLongArray().length != 0) {
            orConstant = (int) OR.toLongArray()[0];
        }

        // Everything that is cleared, needs to be AND-ed.
        BitSet AND =  BitSet.valueOf(new long[]{1023});
        for (int i=0; i<=MAX_INDEX; i++) {
            if (bitStates[i] == State.CLEAR) {
                AND.clear(i);
            }
        }
        int andConstant = 0;
        if (AND.toLongArray().length != 0) {
            andConstant = (int) AND.toLongArray()[0];
        }

        // Everything that is toggled, needs to be XOR-ed.
        BitSet XOR =  BitSet.valueOf(new long[]{0});
        for (int i=0; i<=MAX_INDEX; i++) {
            if (bitStates[i] == State.TOGGLE) {
                XOR.set(i);
            }
        }
        int xorConstant = 0;
        if (XOR.toLongArray().length != 0) {
            xorConstant = (int) XOR.toLongArray()[0];
        }

        System.out.println(3);
        System.out.println("| " + orConstant);
        System.out.println("& " + andConstant);
        System.out.println("^ " + xorConstant);
    }

}

enum State {
    DEFAULT, SET, CLEAR, TOGGLE;
}

class Command {
    enum Operation {
        AND, OR, XOR
    }

    private Operation operation;
    private BitSet constant;
    private int MAX_INDEX;

    public Command(char operator, int constant, int maxIndex) {
        switch (operator) {
            case '&':   this.operation = Operation.AND;
                break;
            case '|':   this.operation = Operation.OR;
                break;
            case '^':   this.operation = Operation.XOR;
                break;
        }
        this.constant = BitSet.valueOf(new long[]{constant});
        this.MAX_INDEX = maxIndex;
    }

    public void apply(State[] states) {
        if (operation == Operation.OR) {
            applyOr(states);
        } else if (operation == Operation.AND) {
            applyAnd(states);
        } else if (operation == Operation.XOR) {
            applyXor(states);
        }
    }

    private void applyOr(State[] states) {
        for (int i = constant.nextSetBit(0); i >= 0; i = constant.nextSetBit(i+1)) {
            if (i > MAX_INDEX) {
                break;
            }
            states[i] = State.SET;
        }
    }

    private void applyAnd(State[] states) {
        for (int i = constant.nextClearBit(0); i >= 0; i = constant.nextClearBit(i+1)) {
            if (i > MAX_INDEX) {
                break;
            }
            states[i] = State.CLEAR;
        }
    }

    private void applyXor(State[] states) {
        for (int i = constant.nextSetBit(0); i >= 0; i = constant.nextSetBit(i+1)) {
            if (i > MAX_INDEX) {
                break;
            }
            if (states[i] == State.DEFAULT) {
                states[i] = State.TOGGLE;
            } else if (states[i] == State.SET) {
                states[i] = State.CLEAR;
            } else if (states[i] == State.CLEAR) {
                states[i] = State.SET;
            } else if (states[i] == State.TOGGLE) {
                states[i] = State.DEFAULT;
            }
        }
    }

}