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.*;

public class Competitive_3 {
		
	public static void main(String[] args) {
		FastReader in = new FastReader();		
		int n = in.nextInt();
		int case1=0, case2=0, case3=0, case4=0;
		ArrayList<Integer> list1=new ArrayList<>(), list2=new ArrayList<>(), list3 = new ArrayList<>();
		String[] arr=new String[n];
		
		for(int i=0;i<n;i++)
			arr[i]=in.nextLine();
		
		for(int i =0;i<10;i++) {
			int n1=(1<<i);
			int n2=0;
			
			for(int j=0;j<n;j++) {
				String[] tempArr=arr[j].split(" ");
				int x = Integer.parseInt(tempArr[1]);
				
				if(tempArr[0].charAt(0)=='|') {
					n1|=x;
					n2|=x;
				}else if(tempArr[0].charAt(0)=='&') {
					n1&=x;
					n2&=x;
				}else {
					n1^=x;
					n2^=x;
				}
				
			}
			
			if((n1&(1<<i))!=0 && (n2&(1<<i))==0) {
				case1++;
			}else if((n1&(1<<i))!=0 && (n2&(1<<i))!=0) {
				case2++;
				list1.add(i);
			}else if((n1&(1<<i))==0 && (n2&(1<<i))!=0) {
				case3++;
				list2.add(i);
			}else {
				case4++;
				list3.add(i);
			}
		}
		
		int cnt=0;
		if(case2!=0) cnt++;
		if(case3!=0) cnt++;
		if(case4!=0) cnt++;
		
        System.out.println(cnt);
        
        if(case2!=0) {
        	int num=0;
        	for(int x:list1) {
        		num|=(1<<x);
        	}
        	System.out.println("| "+(num));
        }
        if(case3!=0) {
        	int num=0;
        	for(int x:list2) {
        		num|=(1<<x);
        	}
        	System.out.println("^ "+(num));
        }
        if(case4!=0) {
        	int num=1023;
        	for(int x:list3) {
        		num^=(1<<x);
        	}
        	System.out.println("& "+(num));
        }
		
	}
	
	static class Pair{
		int x, y;
		
		Pair(int x, int y){
			this.x = x;
			this.y = y;
		}

	}
	
	static class SegmentTree {

		int ST[], arr[];
		int size, n;
		
		public SegmentTree(int arr[]){
			this.arr = arr;
			n = size = arr.length;
			size = (int) Math.ceil(Math.log(size)/Math.log(2));
			size = 2*pow(2, size) + 1;
			
			ST = new int[size];
			build(0, 0, n-1);
		}
		
		/*build segment tree from given array
		 *time: O(n) 
		 */
		private void build(int index, int left, int right){
			if(left == right){
				ST[index] = arr[left];
				return;
			}
			
			int mid = left + (right-left)/2;
			
			build(2*index + 1, left, mid);
			build(2*index + 2, mid+1, right);
			
			ST[index] = Math.max(ST[2*index+1], ST[2*index+2]);
		}
		
		public int query(int queryLeft, int queryRight){
			return query(0, queryLeft, queryRight, 0, n-1);
		}
		
		/*returns the sum from index queryLeft to queryRight
		 *time: O(log n) 
		 */
		private int query(int index, int queryLeft, int queryRight, int left, int right){
			if(queryLeft>right || queryRight<left)
				return Integer.MIN_VALUE;
			
			if(queryLeft<=left && queryRight>=right)
				return ST[index];
			
			int mid = left + (right-left)/2;
			return Math.max( query(2*index + 1, queryLeft, queryRight, left, mid), query(2*index + 2, queryLeft, queryRight, mid+1, right) );
		}
		
		/*returns x^y
		 *time: O(log n) 
		 */
		private static int pow(int x, int y){
			if(y==0){
				return 1;
			}else if(y%2 == 0){
				int temp = pow(x, y/2);
				return temp*temp;
			}else{
				int temp = pow(x, y/2);
				return x*temp*temp;
			}
		}
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	
	
}