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 lab {
    public static void main(String[] args) throws IOException {
        Ifmo ifmo = new Ifmo();
    }
}
class Ifmo {
    int[]  pows;
    int n, t, s, m;
    ArrayList<Edge> e;
    ArrayList<Integer> g[];
    int[] q, d, ptr;
    int INF = 1000000000;
    Ifmo() throws IOException {
        //FScanner fs = new FScanner(new FileReader("kbest.in"));
        FScanner fs = new FScanner(new InputStreamReader(System.in));
        //PrintWriter pw = new PrintWriter(new FileWriter("kbest.out"));
        PrintWriter pw = new PrintWriter(System.out);
        int n =fs.nextInt();
        char[] mas = new char[n];
        int[] m1 = new int[n];
        int and = -1;
        int or = -1;
        int xor= -1;
        int[] bits = new int[10];
        int[] xors = new int[10];
        for (int i =0 ; i<10; i++) {
            bits[i] = -1;
            xors[i] = -1;
        }
        for (int i = 0; i<n; i++) {
            mas[i] = fs.nextChar();
            m1[i] = fs.nextInt();
            int val = bits[2];
            for (int j = 0; j<10; j++) {
                if (mas[i] == '&') {
                    if ((m1[i] & (1<<j)) == 0) {
                        bits[j] = 0;
                        xors[j] = 0;
                    }
                } else if (mas[i] == '|') {
                    if (((m1[i] & (1<<j))) == (1<<j)) {
                        bits[j] = 1;
                        xors[j] = 0;
                    }
                } else {
                    if (((m1[i] & (1<<j))) == (1<<j)) {
                        if (xors[j] == -1)
                            xors[j] = 0;
                        xors[j] = (xors[j] + 1) % 2;

                    }
                }
            }
        }
        boolean ok = true;
        for (int i =0 ; i<10; i++) {
            if (bits[i] != -1 || (xors[i] == 1))
                ok = false;
        }
        if (ok)
            pw.println(0);
        else {
            int count = 0;
            boolean or1 = false, and1 = false, xor1 = false;
            int or2 = 0, and2 = 1023, xor2 = 0;
            for (int i = 0; i<10; i++) {
                if (((xors[i] == 0 || xors[i] == -1) &&bits[i] == 0) || (xors[i] == 1 && bits[i] == 1)) {
                    and1 = true;
                    and2-=Math.pow(2, i);
                    if (xors[i] == bits[i] && bits[i] == 1)
                        xors[i] = 0;
                    bits[i] = 0;
                }
                else if (((xors[i] == 0 || xors[i] == -1) &&bits[i] == 1) || (bits[i] == 0 && xors[i] == 1)) {
                    or1 = true;
                    or2 += Math.pow(2, i);
                    if (bits[i] ==0 && xors[i] == 1) {
                        xors[i] = 0;
                    }
                    bits[i] = 1;
                }
                if (xors[i] == 1) {
                    xor1 = true;
                    xor2 += Math.pow(2, i);
                }
            }
            if (or1 == true)
                count++;
            if (and1 == true)
                count++;
            if (xor1 == true)
                count++;
            pw.println(count);
            if (or1 == true) {
                pw.println("| " + or2);
            }
            if (and1 == true)
                pw.println("& " + and2);
            if (xor1 == true)
                pw.println("^ " + xor2);
        }
        pw.close();
    }
    boolean bfs() {
        int qh = 0, qt = 0;
        q[qt++] = s;
        d = new int[n];
        for (int i =0 ;i <n; i++)
            d[i] = -1;
        d[s] = 0;
        while (qh<qt&&d[t] == -1) {
            int v = q[qh++];
            for (int i =0; i<g[v].size(); i++) {
                int id = g[v].get(i), to = e.get(id).b;
                if (d[to] == -1 && e.get(id).flow < e.get(id).cap) {
                    q[qt++] = to;
                    d[to] = d[v]+1;
                }
            }
        }
        return d[t] !=-1;
    }

    long dfs(int v, int flow) {
        if (flow == 0) return 0;
        if (v == t)
            return flow;
        for (; ptr[v]<g[v].size();  ptr[v]++) {
            int id = g[v].get(ptr[v]), to = e.get(id).b;
            if (d[to] != d[v]+1)
                continue;
            long pushed = dfs(to, Math.min(flow, e.get(id).cap-e.get(id).flow));
            if (pushed!=0) {
                e.get(id).flow +=pushed;
                e.get(id^1).flow -=pushed;
                return pushed;
            }
        }
        return 0;
    }
    long dinic() {
        long flow = 0;
        for (;;) {
            if (!bfs()) break;
            ptr = new int[n];
            long pushed = dfs(s, INF);
            while (pushed !=0){
                flow+=pushed;
                pushed = dfs(s, INF);
            }
        }
        return flow;
    }

}
class Edge {
    int a, b, cap, flow;

    Edge(int a1, int b1, int cap1, int flow1) {
    a =a1;
    b =b1;
    cap =cap1;
    flow =flow1;
}
}
class Triple{
    int x;
    int y;
    int z;
    Triple(int a, int b, int c) {
        x = a;
        y = b;
        z = c;
    }
}

class FScanner {
    StringTokenizer st;
    BufferedReader reader;
    FScanner(InputStreamReader isr) throws IOException {
        reader = new BufferedReader(isr);
    }

    String nextLine() throws IOException {
        return reader.readLine();
    }

    String nextToken() throws IOException{
        while (st == null || !st.hasMoreTokens()) {
            String s = reader.readLine();
            if (s == null)
                return null;
            st = new StringTokenizer(s);
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    char nextChar() throws IOException {
        return (char) reader.read();
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    int[] iarr(int n) throws IOException {
        int[] mas = new int[n];
        for (int i =0 ; i<n; i++)
            mas[i] = nextInt();
        return mas;
    }

    double[] darr(int n) throws IOException {
        double[] mas = new double[n];
        for (int i =0 ; i<n; i++)
            mas[i] = nextDouble();
        return mas;
    }

    char[][] cmas2 (int n, int m) throws IOException {
        char[][] mas = new char[n][m];
        for (int i =0 ; i<n; i++)
            mas[i] = nextLine().toCharArray();
        return mas;
    }

    long[] larr(int n) throws IOException {
        long[] mas = new long[n];
        for (int i =0 ; i<n; i++)
            mas[i] = nextLong();
        return mas;
    }

}