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

public final class xb
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static char[] val=new char[]{'&','|','^'};
	
	static int go(int curr,char ch,int val,int bit)
	{
		int now=((1<<bit)&val)>0?1:0;
		
		if(ch=='^')
		{
			return (curr^now);
		}
		
		else if(ch=='&')
		{
			return (curr&now);
		}
		
		else 
		{
			return (curr|now);
		}
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt();
		
		char[] a=new char[n];int[] op=new int[n];
		
		for(int i=0;i<n;i++)
		{
			a[i]=sc.next().charAt(0);op[i]=sc.nextInt();
		}
		
		int[][] res=new int[2][10];
		
		for(int i=0;i<10;i++)
		{
			for(int k=0;k<2;k++)
			{
				int curr=k;
				
				for(int j=0;j<n;j++)
				{
					curr=go(curr,a[j],op[j],i);
				}
				
				res[k][i]=curr;
			}
		}
		
		int[] ans=new int[3];ans[0]=1023;
		
		for(int i=0;i<10;i++)
		{
			if(res[0][i]==0 && res[1][i]==0)
			{
				ans[0]=(ans[0]^(1<<i));
			}
			
			else if(res[0][i]==0 && res[1][i]==1)
			{
				continue;
			}
			
			else if(res[0][i]==1 && res[1][i]==0)
			{
				ans[2]^=(1<<i);
			}
			
			else
			{
				ans[1]^=(1<<i);
			}
		}
		
		out.println(3);
		
		for(int i=0;i<3;i++)
		{
			out.println(val[i]+" "+ans[i]);
		}
		
		out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}