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.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	// 0 init
	// 1 set 0
	// 2 set 1
	// 3 xor
	private static int[] state = new int[20];
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int i , j , n = scan.nextInt();
		for (i = 0;i < n;i ++) {
			String operation = scan.next();
			int v = scan.nextInt(); 
			if (operation.equals("|")) {
				for (j = 0;j < 10;j ++) {
					if ((v & (1 << j)) != 0) {					
						state[j] = 2;
					}
				}
			} else if (operation.equals("^")) {
				for (j = 0;j < 10;j ++) {
					if ((v & (1 << j)) != 0) {
						if (state[j] == 0) {
							state[j] = 3;
						} else if (state[j] == 3) {
							state[j] = 0;
						} else if (state[j] == 1) {
							state[j] = 2;
						} else {
							state[j] = 1;
						}					
					}
				}
			} else {
				for (j = 0;j < 10;j ++) {
					if ((v & (1 << j)) == 0) {
						state[j] = 1;
					}
				}
			}
		}
		List<String> ans = new ArrayList<>();
		// check set 0
		int value = 0;
		for (i = 0;i < 10;i ++) {
			if (state[i] == 1) {
				value = value | (1 << i);
			}
		}
		if (value > 0) {
			ans.add(String.format("| %d" , value));
			ans.add(String.format("^ %d" , value));
		}
		
		// check set 1
		value = 0;
		for (i = 0;i < 10;i ++) {
			if (state[i] == 2) {
				value = value | (1 << i);
			}
		}
		if (value > 0) {
			ans.add(String.format("| %d" , value));
		}
		
		// check state 3
		value = 0;
		for (i = 0;i < 10;i ++) {
			if (state[i] == 3) {
				value = value | (1 << i);
			}
		}
		if (value > 0) {
			ans.add(String.format("^ %d" , value));
		}
		
		System.out.println(ans.size());
		for (String string : ans) {
			System.out.println(string);
		}
		
	}
	
    
}









	