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 CodeForces{
	public static void main(String[] args) throws IOException{
		Solver Machine = new Solver() ;
		Machine.Solve() ;	
		Machine.Finish();
	}	
}
class Mod{
	static long mod=1000000007 ;
	static long d(long a,long b){ return (a*MI(b))%mod ; }
	static long m(long a , long b){ return (a*b)%mod ; }
	static private long MI(long a ){ return pow(a,mod-2) ; }
	static long pow(long a,long b){
		if(b<0) return pow(MI(a),-b) ;
		long val=a ; long ans=1 ;
		while(b!=0){
			if((b&1)==1) ans = (ans*val)%mod ; 
			val = (val*val)%mod ; 
			b>>=1 ;
		}
		return ans ;
	}	
}
class pair implements Comparable<pair>{
	long x ; long y ; 
	pair(long x,long y){ this.x=x ; this.y=y ;}
	public int compareTo(pair p){
		return (this.x<p.x ? -1 : (this.x>p.x ? 1 : (this.y<p.y ? -1 : (this.y>p.y ? 1 : 0)))) ;
	}
}
class Solver{	
	FasterScanner ip = new FasterScanner(System.in) ;	  
	PrintWriter op = new PrintWriter(System.out) ;
	void Solve() throws IOException{
		int opr[] = new int[10] ;
		for(int i=0 ; i<10 ; i++) opr[i] = 2 ;
		int n = ip.i() ;
		for(int j=0 ; j<n ; j++){
			char c = ip.S().charAt(0) ;
			int vl = ip.i() ;
			for(int i=0 ; i<10 ; i++){
				int bit = vl&1 ;
				switch(c){
					case '&' : {
						if(bit==0) opr[i]=0 ;
					}break ;
					case '|' : {
						if(bit==1) opr[i]=1 ;
					}break ;
					case '^' : {
						if(bit==1){
							if(opr[i]==0 || opr[i]==1) opr[i]=1-opr[i] ;
							else opr[i]=-opr[i] ;
						}
					}
				}
				vl>>=1 ;
			}
		}
		int xor[] = new int[10] ;
		int and[] = new int[10] ;
		Arrays.fill(and,1) ;
		int or[] = new int[10] ;
		for(int i=0 ; i<10 ; i++){ 
			if(opr[i]==-2) xor[i]=1 ;
			if(opr[i]==0) and[i]=0 ;
			if(opr[i]==1) or[i]=1 ;
		}
		/*pArr("opr",opr,'i',0) ;
		pArr("xor",xor,'i',0) ;
		pArr("and",and,'i',0) ;
		pArr("or",or,'i',0) ;*/
		pln(3) ;
		pln("^ "+num(xor)) ;
		pln("& "+num(and)) ;
		pln("| "+num(or)) ;
	}
	int num(int arr[]){
		int res=0 ;
		for(int i=9 ; i>=0 ; i--){
			int bit = arr[i] ;
			res = (res<<1)|bit ;
		}
		return res ;
	}
	void p(Object o){
		op.print(o) ;
	}
	void pln(Object o){
		op.println(o) ;
	}
	void pArr(String name,Object arr,char type,int st){
		p(name+": [") ;
		if(type=='i'){ 
			int arr1[] = (int[]) arr ;
			for(int i=st ; i<arr1.length ; i++) p(arr1[i]+(i+1==arr1.length ? "" : ",")) ;		 
		}else if(type=='l'){ 
			long arr1[] = (long[]) arr ;
			for(int i=st ; i<arr1.length ; i++) p(arr1[i]+(i+1==arr1.length ? "" : ",")) ;
		}else if(type=='b'){
			boolean arr1[] = (boolean[]) arr ;
			for(int i=0 ; i<arr1.length ; i++) p((arr1[i] ? 1 : 0)+(i+1==arr1.length ? "" : ",")) ;
		}
		pln("]") ;
	}	
	void Finish(){
		op.flush();
		op.close();
	}	
}
@SuppressWarnings("serial")
class mylist extends ArrayList<Integer>{
}
@SuppressWarnings("serial")
class myset extends TreeSet<Long>{
}
@SuppressWarnings("serial")
class mystack extends Stack<Integer>{
}
@SuppressWarnings("serial")
class mymap extends TreeMap<Long,Integer>{
}
class FasterScanner { 
	private InputStream mIs;
	private byte[] buf = new byte[1024];
	private int curChar,numChars;
	public FasterScanner() { this(System.in); } 
	public FasterScanner(InputStream is) { mIs = is;} 
	public int read() {
		if (numChars == -1) throw new InputMismatchException();    
		if (curChar >= numChars) {
			curChar = 0;
			try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}
			if (numChars <= 0) return -1;            
		}
		return buf[curChar++];
	} 
	public String nextLine(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	} 
	public String S(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		}while (!isSpaceChar(c));
		return res.toString();
	} 
	public long l(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		int sgn = 1;
		if (c == '-') { sgn = -1 ; c = read() ; }
		long res = 0;
		do{
			if (c < '0' || c > '9') throw new InputMismatchException();
			res *= 10 ; res += c - '0' ; c = read();
		}while(!isSpaceChar(c));
		return res * sgn;
	} 
	public int i(){
		int c = read() ;
		while (isSpaceChar(c)) c = read();        
		int sgn = 1;
		if (c == '-') { sgn = -1 ; c = read() ; }
		int res = 0;
		do{
			if (c < '0' || c > '9') throw new InputMismatchException();
		res *= 10 ; res += c - '0' ; c = read() ;
		}while(!isSpaceChar(c));
		return res * sgn;
	} 
	public int[] ia(int n){
		int a[] = new int[n] ;
		for(int i=0 ; i<n ; i++) a[i] = i() ;
		return a ;
	}
	public long[] la(int n){
		long a[] = new long[n] ;
		for(int i=0 ; i<n ; i++) a[i] = l() ;
		return a ;
	}
	public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
	public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
}