1
& 0
 1
^ 123
 10
^ 218
& 150
| 935
& 61
| 588
& 897
| 411
| 584
^ 800
| 704
 3
& 1
& 3
& 5
 1
| 123
 1
^ 0
 1
| 1023
 3
& 242
^ 506
^ 522
 10
^ 160
& 1021
& 510
^ 470
& 1022
& 251
& 760
& 1016
| 772
| 515
 1
& 1023
 1
| 0
 2
| 56
^ 875
 1
^ 1023
 2
| 999
^ 689
 3
^ 125
^ 377
& 1019
 1
& 123

3
& 0
| 0
^ 0
 3
& 1023
| 0
^ 123
 3
& 763
| 763
^ 0
 3
& 1
| 0
^ 0
 3
& 1023
| 123
^ 0
 3
& 1023
| 0
^ 0
 3
& 1023
| 1023
^ 0
 3
& 1010
| 768
^ 240
 2
| 775
^ 112
 3
& 1023
| 0
^ 0
 3
& 1023
| 0
^ 0
 3
& 983
| 16
^ 835
 3
& 1023
| 0
^ 1023
 3
& 350
| 326
^ 16
 3
& 1019
| 0
^ 256
 3
& 123
| 0
^ 0

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;
        }
    }
	
	
}
