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.Scanner;

public class C {

	public static void main(String[] args) {
		new C();
	}

	Bit num[] = new Bit[10];
	int N = 3;
	int ans[][] = new int[1024][2];
	
	C() {

		Scanner in = new Scanner(System.in);
		N = in.nextInt();
		for(int i=0;i<10;i++) {
			num[i] = new Bit();
		}
		
		for(int i=0;i<1024;i++) {
			ans[i][0] = ans[i][1] = i;
		}
		
		for(int line=0;line<N;line++) {
			char op = in.next().charAt(0);
			int x = in.nextInt();
			switch(op) {
			case '&':
				for(int i=0;i<10;i++) {
					if((x&(1<<i))!=0) { //Great! Bit i is set.
						//preserve state
					}else { //Not great! Bit i is off.
						num[i].state = 0;
					}
				}
//				for(int i=0;i<1024;i++) ans[i][0] &= x;
				break; //berak oboma
			case '|':
				for(int i=0;i<10;i++) {
					if((x&(1<<i))!=0) { //Great! Bit i is set.
						num[i].state = 1;
					}else { //Not great! Bit i is off.
						//preserve state
					}
				}
//				for(int i=0;i<1024;i++) ans[i][0] |= x;
				break;
			case '^':
				for(int i=0;i<10;i++) {
					if((x&(1<<i))!=0) { //Great! Bit i is set.
						num[i].invert();
					}else { //Not great! Bit i is off.
						//preserve state
					}
				}
//				for(int i=0;i<1024;i++) ans[i][0] ^= x;
				break;
			}
		}
		
		System.out.println("3");
		int mask = preserved(num);
		System.out.println("& "+mask);
		int flippity = flipped(num);
		System.out.println("^ "+flippity);
		int lit = literal(num);
		System.out.println("| "+lit);
		
//		for(int i=0;i<1024;i++) {
//			ans[i][1] &= mask;
//			ans[i][1] ^= flippity;
//			ans[i][1] |= lit;
//			if(ans[i][1]!=ans[i][0]) {
//				System.out.printf("Uh-oh, we got a problem up in here! %d didn't match.\n",i);
//				return;
//			}
//		}
		
//		System.out.println("Nice. Your code works.");
		
		in.close();

	}
	
	int preserved(Bit[] num) {
		int ans = 0;
		for(int i=0;i<num.length;i++){
			if(num[i].state==2 || num[i].state==3) {
				ans |= (1<<i);
			}
		}
		return ans;
	}
	
	int flipped(Bit[] num) {
		int ans = 0;
		for(int i=0;i<num.length;i++){
			if(num[i].state==3) {
				ans |= (1<<i);
			}
		}
		return ans;
	}
	
	int literal(Bit[] num) {
		int ans = 0;
		for(int i=0;i<num.length;i++){
			if(num[i].state==1) {
				ans |= (1<<i);
			}
		}
		return ans;
	}
	
	static class Bit{
		/**
		 * 0 = 0
		 * 1 = 1
		 * 2 = preserved
		 * 3 = inverted
		 */
		int state;
		
		public Bit() {
			state = 2;
		}
		
		public void invert() {
			if(state==1)
				state = 0;
			else if(state==0)
				state = 1;
			else if(state==2)
				state = 3;
			else
				state = 2;
		}
	}
	
}
