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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author phantom11
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int a[] = new int[10];
            Arrays.fill(a, -1);
            int i, j;
            for (i = 0; i < n; i++) {
                char symbol = in.next().charAt(0);
                int num = in.nextInt();
                String s = Integer.toBinaryString(num);
                while (s.length() < 10) {
                    s = "0" + s;
                }
                int index = 0;
                if (symbol == '&') {
                    for (j = s.length() - 1; j >= 0; j--) {
                        if (s.charAt(j) == '0') {
                            a[index] = 0;
                        }
                        index++;
                    }
                } else if (symbol == '|') {
                    for (j = s.length() - 1; j >= 0; j--) {
                        if (s.charAt(j) == '1') {
                            a[index] = 1;
                        }
                        index++;
                    }
                } else {
                    for (j = s.length() - 1; j >= 0; j--) {
                        if (s.charAt(j) == '1') {
                            if (a[index] == 1) {
                                a[index] = 0;
                            } else if (a[index] == -1) {
                                a[index] = -2;
                            } else if (a[index] == -2) {
                                a[index] = -1;
                            } else if (a[index] == 0) {
                                a[index] = 1;
                            }
                        }
                        index++;
                    }
                }
            }
            int count = 0, zero = 0, one = 0, two = 0;
            for (i = 0; i < 10; i++) {
                if (a[i] != -1) {
                    count++;
                }
                if (a[i] == 0) {
                    zero++;
                }
                if (a[i] == 1) {
                    one++;
                }
                if (a[i] == -2) {
                    two++;
                }
            }
            if (count == 0) {
                out.printLine(0);
                return;
            }
            //DebugUtils.debug(a);
            ArrayList<Character> symbols = new ArrayList<>();
            ArrayList<Integer> numbers = new ArrayList<>();
            StringBuilder str = new StringBuilder("");
            StringBuilder another = new StringBuilder("");
            StringBuilder twos = new StringBuilder("");
            for (i = 0; i < 10; i++) {
                if (a[i] == 1) {
                    str.append(1);
                } else {
                    str.append(0);
                }
                if (a[i] == 0) {
                    another.append(0);
                } else {
                    another.append(1);
                }
                if (a[i] == -2) {
                    twos.append(1);
                } else {
                    twos.append(0);
                }
            }
            str = str.reverse();
            another = another.reverse();
            twos = twos.reverse();
            if (one > 0) {
                symbols.add('|');
                numbers.add(Integer.parseInt(str.toString(), 2));
            }
            if (zero > 0) {
                symbols.add('&');
                numbers.add(Integer.parseInt(another.toString(), 2));
            }
            if (two > 0) {
                symbols.add('^');
                numbers.add(Integer.parseInt(twos.toString(), 2));
            }
            out.printLine(symbols.size());
            for (i = 0; i < symbols.size(); i++) {
                out.printLine(symbols.get(i) + " " + numbers.get(i));
            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(in.readLine());
                }
                return tokenizer.nextToken();
            } catch (IOException e) {
                return null;
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}