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 ShortProgram {

	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		run(sc, out);
		out.close();
	}

	public static void run(FastScanner sc, PrintWriter out) throws Exception {
		int N = sc.nextInt();
		int[] arr = new int[1024];
		for (int i = 0; i < 1024; i++) {
			arr[i] = i;
		}
		for (int i = 0; i < N; i++) {
			int op = sc.readOutSpaces();
			int num = sc.nextInt();

			if (op == '&') {
				for (int j = 0; j < 1024; j++) {
					arr[j] &= num;
				}
			} else if (op == '|') {
				for (int j = 0; j < 1024; j++) {
					arr[j] |= num;
				}

			} else if (op == '^') {
				for (int j = 0; j < 1024; j++) {
					arr[j] ^= num;
				}

			} else {
				throw new Exception("input mismatch");
			}
		}
		int[][] bits = new int[10][2];
		for (int[] a : bits)
			Arrays.fill(a, -1);
		for (int num = 0; num < 1024; num++) {
			for (int i = 0; i < 10; i++) {
				int bit = (num & (1 << i)) == 0 ? 0 : 1;
				int resultBit = (arr[num] & (1 << i)) == 0 ? 0 : 1;
				bits[i][bit] = resultBit;
			}
		}
		int count = 0;
		int and = 0;
		int or = 0;
		int xor = 0;
		for (int i = 0; i < 10; i++) {
			int bit = 1 << i;
			boolean b1 = bits[i][0] != 0;
			boolean b2 = bits[i][1] != 1;
			if (b1 && b2) {
				and |= bit;
				xor |= bit;
			} else if (b1) {
				and |= bit;
				or |= bit;
			} else if (b2) {

			} else {
				and |= bit;
			}
		}
		int[] results = new int[1024];
		for (int i = 0; i < 1024; i++) {
			results[i] = i;
			results[i] &= and;
			results[i] |= or;
			results[i] ^= xor;
			if (results[i] != arr[i]) {
				System.out.println("RIP");
			}
		}

		System.out.println("3\n& " + and + "\n| " + or + "\n^ " + xor);
	}

	static class FastScanner {
		final private int BUFFER_SIZE = 1 << 20;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public FastScanner(InputStream stream) {
			din = new DataInputStream(stream);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public FastScanner(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		String nextLine() throws IOException {
			int c = read();
			while (c != -1 && isEndline(c))
				c = read();
			if (c == -1) {
				return null;
			}
			StringBuilder res = new StringBuilder();
			do {
				if (c >= 0) {
					res.appendCodePoint(c);
				}
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		String next() throws Exception {
			int c = readOutSpaces();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		private int readOutSpaces() throws IOException {
			while (true) {
				if (bufferPointer == bytesRead)
					fillBuffer();
				int c = buffer[bufferPointer++];
				if (!isSpaceChar(c)) {
					return c;
				}
			}
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}

}