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:
/**
 * DA-IICT
 * Author : Savaliya Sagar
 */
import java.io.*;
import java.math.*;
import java.util.*;

import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;

public class C879
{
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	char c[];
	int x[];
	int b0[] = new int[10];
	int b1[] = new int[10];
	char c1[];
	int x1[];
	void solve()
	{
		int n = ni();
		c = new char[n];
		x = new int[n];
		c1 = new char[]{'^','|','&'};
		x1 = new int[3];
		for(int i=0;i<n;i++){
			c[i] = nc();
			x[i] = ni();
		}
//		tr(c);
		fun(0,n);
		fun(1023,n);
//		tr(b0);
//		tr(b1)	;
		out.println(3);
		int num = 0;
		for(int i=0;i<10;i++){
			if(b0[i]==1 && b1[i]==0){
				num |= (1<<i);
			}
		}
		out.println("^ " + num);
		x1[0] = num;
		
		num = 0;
		for(int i=0;i<10;i++){
			if(b0[i]==1 && b1[i]==1){
				num |= (1<<i);
			}
		}
		out.println("| " + num);
		x1[1] = num;
		num = 0;
		for(int i=0;i<10;i++){
			if(b0[i]==0 && b1[i]==0){
				;
			}else
				num |= (1<<i);
		}
		out.println("& " + num);	
		x1[2] = num;
//		for(int i=0;i<1024;i++){
//			if(fun1(i,3)!=fun2(i,n))
//				out.println("ERROR");
//		}
	}
	
	void fun(int f,int n){
		int l = f;
		for(int i=0;i<n;i++){
			if(c[i]=='|')
				f |= x[i];
			else if(c[i]=='&')
				f &= x[i];
			else
				f ^= x[i];
		}
		//out.println(Integer.toBinaryString(f));
		if(l==0){
			for(int i=0;i<10;i++){
				b0[i] = (f>>i)&1;
			}
		}else{
			for(int i=0;i<10;i++){
				b1[i] = (f>>i)&1;
			}
		}
	}
	int fun1(int f,int n){
		int l = f;
		for(int i=0;i<n;i++){
			if(c1[i]=='|')
				f |= x1[i];
			else if(c1[i]=='&')
				f &= x1[i];
			else
				f ^= x1[i];
		}
		return f;
	}
	int fun2(int f,int n){
		int l = f;
		for(int i=0;i<n;i++){
			if(c[i]=='|')
				f |= x[i];
			else if(c[i]=='&')
				f &= x[i];
			else
				f ^= x[i];
		}
		return f;
	}
	void run() throws Exception
	{
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}
	
	public static void main(String[] args) throws Exception
	{
		new Thread(null, new Runnable()
		{
			public void run()
			{
				try
				{
					new C879().run();
				} catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try
			{
				lenbuf = is.read(inbuf);
			} catch (IOException e)
			{
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c)
	{
		return !(c >= 33 && c <= 126);
	}
	
	private int skip()
	{
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}
	
	private double nd()
	{
		return Double.parseDouble(ns());
	}
	
	private char nc()
	{
		return (char) skip();
	}
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b)))
		{ // when nextLine, (isSpaceChar(b) && b !=
				// ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b)))
		{
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while (true)
		{
			if (b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			} else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-')
		{
			minus = true;
			b = readByte();
		}
		
		while (true)
		{
			if (b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			} else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private void tr(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}