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.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.Scanner;

public class Kek {
	static int op_xor(int a, int b) {
		return a ^ b;
	}

	static int op_and(int a, int b) {
		return a & b;
	}

	static int op_or(int a, int b) {
		return a | b;
	}

	static int[] to_bin(int x) {
		int i = 9;
		int ans[] = new int[10];
		while (x != 0) {
			ans[i--] = x % 2;
			x /= 2;
		}
		return ans;
	}

	static int from_bin(int a, int b, int c, int mas[]) {
		int x = 0;
		int k = 1;
		for (int i = mas.length - 1; i >= 0; i--) {
			if (mas[i] == a)
				x += k * b;
			else
				x += k * c;
			k *= 2;
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int mas[][] = new int[n][10];
		char op[] = new char[n];
		int ans[] = new int[10];
		for (int i = 0; i < n; i++) {
			op[i] = in.next().charAt(0);
			mas[i] = to_bin(in.nextInt());
		}
		for (int i = 9; i >= 0; i--) {
			int a = 0;
			int b = 1;
			for (int j = 0; j < n; j++) {
				if (op[j] == '^') {
					a = op_xor(a, mas[j][i]);
					b = op_xor(b, mas[j][i]);
				} else if (op[j] == '|') {
					a = op_or(a, mas[j][i]);
					b = op_or(b, mas[j][i]);
				} else {
					a = op_and(a, mas[j][i]);
					b = op_and(b, mas[j][i]);
				}
			}
			if (a == 0 && b == 0)
				ans[i] = 2;
			else if (a == 0 && b == 1)
				ans[i] = 0;
			else if (a == 1 && b == 1)
				ans[i] = 1;
			else
				ans[i] = -1;
		}
		out.println(3);
		out.println("& " + from_bin(2, 0, 1, ans));
		out.println("| " + from_bin(1, 1, 0, ans));
		out.print("^ " + from_bin(-1, 1, 0, ans));
		in.close();
		out.close();
	}
}