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

public class A implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

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

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

    double readDouble() {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new A().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();

//            for (int x = 0; x < 1024; x++) {
//                int x1 = x;
//                x1 &= 1020;
//                x1 ^= 0;
//                x1 |= 1;
//
//                int x2 = x;
//                x2 |= 3;
//                x2 ^= 2;
//                x2 |= 1;
//
//                if (x1 != x2) {
//                    throw new RuntimeException();
//                }
//            }

            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int[][] buildGraph(int n, int[] u, int[] v) {
        int[][] graph = new int[n][];
        int[] q = new int[n];
        for (int i = 0; i < u.length; i++) {
            q[u[i]]++;
            q[v[i]]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[q[i]];
        }
        for (int i = 0; i < u.length; i++) {
            graph[u[i]][--q[u[i]]] = v[i];
            graph[v[i]][--q[v[i]]] = u[i];
        }
        return graph;
    }

    private int aiverson(boolean good) {
        return good ? 1 : 0;
    }

    int BITS = 10;

    boolean has(int mask, int bit) {
        return Integer.bitCount(mask & (1 << bit)) > 0;
    }

    private void solve() {
        int n = readInt();
        int[] forSure = new int[BITS];
        boolean[] reversed = new boolean[BITS];
        Arrays.fill(forSure, -1);
        for (int i = 0; i < n; i++) {
            String op = readString();
            int mask = readInt();
            if ("|".equals(op)) {
                for (int bit = 0; bit < BITS; bit++) {
                    if (has(mask, bit)) {
                        forSure[bit] = 1;
                    }
                }
            } else if ("&".equals(op)){
                for (int bit = 0; bit < BITS; bit++) {
                    if (!has(mask, bit)) {
                        forSure[bit] = 0;
                    }
                }
            } else {
                for (int bit = 0; bit < BITS; bit++) {
                    if (has(mask, bit)) {
                        if (forSure[bit] == -1) {
                            reversed[bit] ^= true;
                        } else {
                            forSure[bit] ^= 1;
                        }
                    }
                }
            }
        }

        out.println(3);
        int mask = 0;
        for (int i = 0; i < BITS; i++) {
             if (forSure[i] == -1) {
                 mask |= (1 << i);
             }
        }
        out.println("& " + mask);

        mask = 0;
        for (int i = 0; i < BITS; i++) {
            if (forSure[i] == -1 && reversed[i]) {
                mask |= (1 << i);
            }
        }
        out.println("^ " + mask);

        mask = 0;
        for (int i = 0; i < BITS; i++) {
            if (forSure[i] != -1 && forSure[i] == 1) {
                mask |= (1 << i);
            }
        }
        out.println("| " + mask);
    }
}