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

public class Competitive_1 {
	
	static final int L=1, R=2, U=3, D=4, bias=10000;
	static int dx[]={0,0,-1,1}, dy[]={-1,1,0,0};
	static int n, m, k;
	static char arr[][];
	static int min[][];
	static boolean visited[][][];
	
	public static void main(String[] args) {
		
		new Thread(null, new Runnable(){
					@Override
					public void run(){
						soln();
					}
			}, "1", 1 << 26).start();
		
	}
	
	static void soln(){
		FastReader in = new FastReader();
		int n = in.nextInt();
		String arr[] = new String[n];
		int n0=0x0, n1=0x3FF;
		
		for(int i=0; i<n; i++){
			String op = in.nextLine();
			int num = Integer.parseInt(op.substring(2));
			
			if(op.charAt(0)=='|'){
				n0 |= num;
				n1 |= num;
			}else if(op.charAt(0)=='&'){
				n0 &= num;
				n1 &= num;
			}else{
				n0 ^= num;
				n1 ^= num;
			}
		}
		
		int or=0, and=0x3FF;
		for(int i=0; i<10; i++){
			int nn0 = n0 & (1<<i), nn1 = n1 & (1<<i);
			
			if(nn0==0 && nn1==0){
				and ^= 1<<i;
			}else if(nn0>0 && nn1>0){
				or ^= 1<<i;
			}
		}
		
		System.out.println(2);
		System.out.println("& " + and);
		System.out.println("| " + or);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	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;
        }
    }
	
}