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

public class main
{
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	private static long mod = 1000000000 + 7;

	private static void soln()
	{
		/*int n = nextInt();
		long k = nextLong();
		int[] arr = new int[n];
		int max = Integer.MIN_VALUE;
		for(int i=0;i<n;i++) {
			arr[i] = nextInt();
			max = Math.max(arr[i], max);
		}
		if(k>=n-1)
			pw.println(max);
		else {
			int max1 = Math.max(arr[0],arr[1]);
			int k1 = 1;
			for(int i=2;i<n && k1<=k; i++) {
				if(max1<arr[i]) {
					k1++;
					max1 = arr[i];
				}else
					k1 = 1;
				if(k1==k)
					break;
			}
			pw.println(max1);
		}*/
		int n = nextInt();
		ArrayList<Integer>[] l = new ArrayList[4];
		for(int i=0;i<4;i++)
			l[i] = new ArrayList<>();
		String[][] arr = new String[n][2];
		for(int i=0;i<n;i++)
			arr[i] = nextLine().split(" ");
		for(int i=0;i<10;i++) {
			int b1 = 0;
			int b2 = 1;
			for(int j=0;j<n;j++) {
				int bit = Integer.parseInt(arr[j][1]);
				bit = ((bit&(1<<i))>>i);
				if(arr[j][0].charAt(0)=='|') {
					b1 |= bit;
					b2 |= bit;
				}
				else if(arr[j][0].charAt(0)=='&') {
					b1 &= bit;
					b2 &= bit;
				}
				else {
					b1 ^= bit;
					b2 ^= bit;
				}
			}
			if(b1 == 0 && b2 == 1) {
				l[0].add(i);
			}else if(b1 == 1 && b2 == 1) {
				l[1].add(i);
			}else if(b1 == 0 && b2 == 0) {
				l[2].add(i);
			}else {
				l[3].add(i);
			}
		}
		pw.println(3);
		int num = 0;
		for(int x: l[1]) {
			num += (1<<x);
		}
		pw.println("| "+num);
		num = 1023;
		for(int x: l[2]) {
			num ^= (1<<x);
		}
		pw.println("& "+num);
		num = 0;
		for(int x: l[3]) {
			num += (1<<x);
		}
		pw.println("^ "+num);
	}
	
	private static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	
	private static class Pair implements Comparable<Pair>{
		long val;
		int br;
		public Pair(long a,int b) {
			val=a;
			br=b;
		}
		@Override
		public int compareTo(Pair arg0)
		{
			return (int) (this.val-arg0.val);
		}
	}
	private static long pow(long a, long b, long c)
	{
		if (b == 0)
			return 1;
		long p = pow(a, b / 2, c);
		p = (p * p) % c;
		return (b % 2 == 0) ? p : (a * p) % c;
	}

	private static long gcd(long n, long l)
	{
		if (l == 0)
			return n;
		return gcd(l, n % l);
	}

	public static void main(String[] args) throws Exception
	{
//		new Thread(null, new Runnable()
//		{
//			@Override
//			public void run()
//			{
//				/*
//				 * try { InputReader(new
//				 * FileInputStream("C:\\Users\\hardik\\Desktop\\B-large-practice.in")); } catch
//				 *) (FileNotFoundException e) { // TODO Auto-generated catch block
//				 * e.printStackTrace(); }
//				 */
//				InputReader(System.in);
//				pw = new PrintWriter(System.out);
//				/*
//				 * try { pw=new PrintWriter(new
//				 * FileOutputStream("C:\\Users\\hardik\\Desktop\\out.txt")); } catch
//				 * (FileNotFoundException e) { // TODO Auto-generated catch block
//				 * e.printStackTrace(); }
//				 */
//				soln();
//				pw.close();
//			}
//		}, "1", 1 << 26).start();

		/*
		 * try { InputReader(new
		 * FileInputStream("C:\\Users\\hardik\\Desktop\\B-large-practice.in")); } catch
		 * (FileNotFoundException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 */
		 InputReader(System.in);
		 pw = new PrintWriter(System.out);
		/*
		 * try { pw=new PrintWriter(new
		 * FileOutputStream("C:\\Users\\hardik\\Desktop\\out.txt")); } catch
		 * (FileNotFoundException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 */
		soln();
		pw.close();
	}

	public static void InputReader(InputStream stream1)
	{
		stream = stream1;
	}

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

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

	private static int read()
	{
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars)
		{
			curChar = 0;
			try
			{
				numChars = stream.read(buf);
			} catch (IOException e)
			{
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nextInt()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-')
		{
			sgn = -1;
			c = read();
		}
		int res = 0;
		do
		{
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static long nextLong()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-')
		{
			sgn = -1;
			c = read();
		}
		long res = 0;
		do
		{
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private static String nextToken()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static String nextLine()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private static int[] nextIntArray(int n)
	{
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n)
	{
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
		{
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static boolean isSpaceChar(int c)
	{
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private static char nextChar()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1 = (char) c;
		while (!isSpaceChar(c))
			c = read();
		return c1;
	}

	private interface SpaceCharFilter
	{
		public boolean isSpaceChar(int ch);
	}
}