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.util.Map.Entry;
import java.lang.Math;
import java.math.BigInteger;

public class Problem {
	class Pair {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	class Doc implements Comparable<Doc>{
		int start;
		int rep;
		Doc(int start, int rep){
			this.start = start;
			this.rep = rep;
		}
		@Override
		public int compareTo(Doc other) {
			if(this.start>other.start){
				return 1;
			}
			if(this.start<other.start){
				return -1;
			}
			if(this.rep<other.rep){
				return 1;
			}
			return -1;
		}
	}
	void solve() throws IOException {
		int n = rI();

		
		int[] op_arr = new int[11];
		
		Arrays.fill(op_arr, -1);
		
		for(int i=0;i<n;++i){
			char op = rS().toCharArray()[0];
			int next = rI();
			if(op=='|'){
				for(int bit=0;bit<=10;++bit){
					if(checkBit(next, bit)==1){
						op_arr[bit] = 1;
					}
				}
			}
			if(op=='&'){
				for(int bit=0;bit<=10;++bit){
					if(checkBit(next, bit)==0){
						op_arr[bit] = 0;
					}
				}
			}
			if(op=='^'){
				for(int bit=0;bit<=10;++bit){
					if(checkBit(next, bit)==1){
						if(op_arr[bit]==0){
							op_arr[bit]=1;
						}else if(op_arr[bit]==1){
							op_arr[bit]=0;
						}else if(op_arr[bit]==2){
							op_arr[bit] = -1;
						}else{
							op_arr[bit] = 2;
						}
					}
				}
			}
		}
		int xor = 0;
		boolean isXor = false;
		int or = 0;
		boolean isOr = false;
		int and = (int)Math.pow(2, 10)-1;
		boolean isAnd = false;
		for(int i=0;i<10;++i){
			if(op_arr[i]==0){
				isAnd = true;
				and -= (int)Math.pow(2, i);
			}
			if(op_arr[i]==1){
				isOr = true;
				or += (int)Math.pow(2, i);
			}
			if(op_arr[i]==2){
				isXor = true;
				xor += (int)Math.pow(2, i);
			}
		}
		int count = 0;
		if(isOr) count++;
		if(isXor) count++;
		if(isAnd) count++;
		out.println(count);
		if(isOr) out.println("| "+or);
		if(isAnd) out.println("& "+and);
		if(isXor) out.println("^ "+xor);

	}
	int checkBit(int mask, int bit) {
		return (mask >> bit) & 1;
	}
	public static void main(String[] args) throws IOException {

		new Problem().run();
	}

	boolean isLower(char a) {
		return ((int) a) >= 97 ? true : false;
	}

	int INF = Integer.MAX_VALUE - 12345;

	int[][] STEPS = { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } };

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;
	Random rnd = new Random();
	static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

	Problem() throws FileNotFoundException {

		if (ONLINE_JUDGE) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader("input.txt"));
			out = new PrintWriter("output.txt");
		}
		tok = new StringTokenizer("");
	}

	long checkBit(long mask, int bit) {
		return (mask >> bit) & 1;
	}

	// ======================================================

	// ======================================================
	void run() throws IOException {
		solve();
		out.close();
	}

	char[] reverseCharArray(char[] arr) {
		char[] ans = new char[arr.length];
		for (int i = 0; i < arr.length; ++i) {
			ans[i] = arr[arr.length - i - 1];
		}
		return ans;
	}

	int sqrt(double m) {
		int l = 0;
		int r = 1000000000 + 9;
		int i = 1000;
		while (r - l > 1) {
			int mid = (r + l) / 2;
			if (mid * mid > m) {
				r = mid;
			} else {
				l = mid;
			}
		}
		return l;
	}

	int countPow(int m, int n) {
		int ans = 0;
		while (m % n == 0 && m > 0) {
			ans++;
			m /= n;
		}
		return ans;
	}

	long binPow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b % 2 == 1) {
			return a * binPow(a, b - 1);
		} else {
			long c = binPow(a, b / 2);
			return c * c;
		}

	}

	int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	long pow(long x, long k) {
		long ans = 1;
		for (int i = 0; i < k; ++i) {
			ans *= x;
		}
		return ans;
	}

	// ////////////////////////////////////////////////////////////////////

	String delimiter = " ";

	String readLine() throws IOException {
		return in.readLine();
	}

	String rS() throws IOException {
		while (!tok.hasMoreTokens()) {
			String nextLine = readLine();
			if (null == nextLine)
				return null;

			tok = new StringTokenizer(nextLine);
		}

		return tok.nextToken(delimiter);
	}

	int rI() throws IOException {
		return Integer.parseInt(rS());
	}

	long rL() throws IOException {
		return Long.parseLong(rS());
	}

	double rD() throws IOException {
		return Double.parseDouble(rS());
	}

	int[] rA(int b) {
		int a[] = new int[b];
		for (int i = 0; i < b; i++) {
			try {
				a[i] = rI();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return a;
	}

	int[] readSortedIntArray(int size) throws IOException {
		Integer[] array = new Integer[size];

		for (int index = 0; index < size; ++index) {
			array[index] = rI();
		}
		Arrays.sort(array);

		int[] sortedArray = new int[size];
		for (int index = 0; index < size; ++index) {
			sortedArray[index] = array[index];
		}

		return sortedArray;
	}

	int[] sortedIntArray(int size, int[] array) throws IOException {
		for (int index = 0; index < size; ++index) {
			array[index] = rI();
		}
		Arrays.sort(array);

		int[] sortedArray = new int[size];
		for (int index = 0; index < size; ++index) {
			sortedArray[index] = array[index];
		}

		return sortedArray;
	}
}