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 c{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line;
		
		line = br.readLine().split(" ");
		int N = Integer.parseInt(line[0]);
		
		// 0 is 0, 1 is 1, 2 is ?, 3 is upsidedown?
		int[] type = new int[10];
		Arrays.fill(type, 2);
		
		for(int n=0;n<N;n++){
			line = br.readLine().split(" ");
			char ch = line[0].charAt(0);
			int a = Integer.parseInt(line[1]);
			if(ch == '&'){
				for(int i = 0; i < 10; i++){
					if((1 << i | a) == a){
						
						
						
					}
				}
			}
			for(int i = 0; i < 10; i++){
				// not in the set
				if((1 << i | a) != a){
					if(ch == '&'){
						type[i] = 0;
					}
				}
				// in the set
				if((1 << i | a) == a){
					if(ch == '|'){
						type[i] = 1;
					}
					if(ch == '^'){
						// 0s become 1s, and vice versa
						// still undecided things flip their outputs
						if(type[i] % 2 == 0) type[i]++;
						else type[i]--;
					}
				}
			}
			
		}

		// find:
		// an integer that covers all bits except the 0s
		// an integer that covers all the 1s
		// an integer that covers all the flip-outputs
		int allButZero = 0, allOne = 0, allFlip = 0;
		for(int i = 0; i < 10; i++){
			if(type[i] != 0) allButZero += (1<<i);
			if(type[i] == 1) allOne += (1<<i);
			if(type[i] == 3) allFlip += (1<<i);
		}
		
		System.out.println(3);
		System.out.println("& "+allButZero);
		System.out.println("| "+allOne);
		System.out.println("^ "+allFlip);
	}
}