Problem: 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.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main {
    static final int and = 1;
    static final int or = 2;
    static final int xor = 3;
    static final int reversed = 1;
    static final int unchanged = 2;
    static final int one = 3;
    static final int zero = 4;

    static int getEffect(int a[], int op[]) {
//        for (int i = 0; i < a.length; i++) System.out.print(a[i] + " "); System.out.println();
//        for (int i = 0; i < op.length; i++) System.out.print(op[i] + " "); System.out.println();
        int resOne = 1;
        int n = a.length;
        for (int i = 0; i < n; i++) {
            switch (op[i]) {
                case and: resOne &= a[i]; break;
                case or: resOne |= a[i]; break;
                case xor: resOne ^= a[i]; break;
            }
        }
        int resZero = 0;
        for (int i = 0; i < n; i++) {
            switch (op[i]) {
                case and: resZero &= a[i]; break;
                case or: resZero |= a[i]; break;
                case xor: resZero ^= a[i]; break;
            }
        }
//        System.out.println(resOne + " " + resZero);
        if (resOne == 1 && resZero == 0) return unchanged;
        if (resOne == 0 && resZero == 1) return reversed;
        if (resOne == 1 && resZero == 1) return one;
        if (resOne == 0 && resZero == 0) return zero;
        return -1;
    }

    static int getVal(int bit[]) {
        int n = bit.length;
        int res = 0;
        int curr = 1;
        for (int i = 0; i < n; i++) {
            res += bit[i] * curr;
            curr *= 2;
        }
        return res;
    }

    static void solve() throws IOException {
//        input = new BufferedReader(new FileReader("/home/noberel/Downloads/Software Construction/problems/src/main/java/input"));
//        output = new BufferedWriter((new FileWriter("/home/noberel/Downloads/Software Construction/problems/src/main/java/output")));
        int n = ni1();
        int a[][] = new int[10][n];
        int op[] = new int[n];
        for (int i = 0; i < n; i++) {
            rl();
            String s = rl2(); int k = ni2();
            switch (s) {
                case "&":
                    op[i] = and;
                    break;
                case "|":
                    op[i] = or;
                    break;
                default:
                    op[i] = xor;
                    break;
            }
            for (int j = 0; j < 10; j++) {
                a[j][i] = (k & (1<<j)) == 0 ? 0 : 1;
            }
        }
        int nXOR[] = new int[10];
        int nAND[] = new int[10];
        int nOR[] = new int[10];
        for (int i = 0; i < 10; i++) {
            int effect = getEffect(a[i], op);
            switch (effect) {
                case reversed:
                    nXOR[i] = 1; nAND[i] = 1; nOR[i] = 0; break;
                case unchanged:
                    nXOR[i] = 0; nAND[i] = 1; nOR[i] = 0; break;
                case one:
                    nXOR[i] = 0; nAND[i] = 1; nOR[i] = 1; break;
                case zero:
                    nXOR[i] = 0; nAND[i] = 0; nOR[i] = 0; break;
            }
        }
        ans.append("3\n");
        ans.append("^ ").append(getVal(nXOR)).append('\n');
        ans.append("& ").append(getVal(nAND)).append('\n');
        ans.append("| ").append(getVal(nOR)).append('\n');
        output.write(ans.toString());
        output.flush();
        output.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    static BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
    static StringBuilder ans = new StringBuilder();
    static String line;
    static StringTokenizer stringTokenizer;

    static int ni1() throws IOException {
        return Integer.parseInt(input.readLine());
    }

    static int ni2() throws IOException {
        return Integer.parseInt(stringTokenizer.nextToken());
    }

    static long nl1() throws IOException {
        return Long.parseLong(input.readLine());
    }

    static long nl2() {
        return Long.parseLong(stringTokenizer.nextToken());
    }

    static void rl() throws IOException {
        stringTokenizer = new StringTokenizer(input.readLine());
    }

    static String rl2() throws IOException {
        return stringTokenizer.nextToken();
    }
}