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.*;
import java.util.*;

public class Main {
    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;


    void solve() throws IOException {
        int max = 1023;
        int min = 0;
        int n = readInt();
        int val = 0;
        while (n-- > 0) {
            String str = readString();
            val = readInt();
            if (str.charAt(0) == '|') {
                max |= val;
                min |= val;
            }
            if (str.charAt(0) == '&') {
                max &= val;
                min &= val;
            }
            if (str.charAt(0) == '^') {
                max ^= val;
                min ^= val;
            }
        }
        int[][] arr = new int[10][2];
        for (int i = 0; i < 10; i++) {
            arr[i][0] = min % 2;
            min /= 2;
        }
        for (int i = 0; i < 10; i++) {
            arr[i][1] = max % 2;
            max /= 2;
        }
        //or xor and
        int answer[][] = new int[10][3];
        for (int i = 0; i < 10; i++) {
            if(arr[i][0]==0&&arr[i][1]==0) continue;
            if(arr[i][0]==1&&arr[i][1]==0){
                answer[i][1]++;
                answer[i][2]++;
            }
            if(arr[i][0]==1&&arr[i][1]==1){
                answer[i][2]++;
                answer[i][0]++;
            }
            if(arr[i][0]==0&&arr[i][1]==1){
                answer[i][2]++;
            }
        }
        int xor =0;
        int or=0;
        int and =0;
        for (int i =0;i<10;i++){
            or+=answer[i][0]*Math.pow(2,i);
        }
        for (int i =0;i<10;i++){
            xor+=answer[i][1]*Math.pow(2,i);
        }
        for (int i =0;i<10;i++){
            and+=answer[i][2]*Math.pow(2,i);
        }
        out.println(3);
        out.println("& "+and);
        out.println("| "+or);
        out.println("^ "+xor);
    }

    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) {
            max = Math.max(max, value);
        }
        return max;
    }

    long minLong(long... values) {
        long min = Long.MAX_VALUE;
        for (long value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    long maxLong(long... values) {
        long min = Long.MIN_VALUE;
        for (long value : values) {
            min = Math.max(min, value);
        }
        return min;
    }

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

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;


    void init() throws FileNotFoundException {
        if (ONLINE_JUDGE) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
        tok = new

                StringTokenizer("");

    }

    void run() {
        try {
            long timeStart = System.currentTimeMillis();

            init();
            solve();

            out.close();

            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeStart) + " COMPILED");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((-memoryTotal + memoryFree) >> 10) + " KB");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String delimiter = " ";

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine)
                return null;

            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken(delimiter);
    }

    int[] readArray(int b) {
        int a[] = new int[b];
        for (int i = 0; i < b; i++) {
            try {
                a[i] = readInt();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return a;
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }


    void sortArrayInteger(int[] a) {
        Integer arr[] = new Integer[a.length];
        for (int i = 0; i < a.length; i++) {
            arr[i] = a[i];
        }
        Arrays.sort(arr);
        for (int i = 0; i < a.length; i++) {
            a[i] = arr[i];
        }
    }

}