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.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	static BufferedReader br;
    static StringTokenizer sc;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        //br = new BufferedReader(new FileReader("input.in"));
    	br = new BufferedReader(new InputStreamReader(System.in));
        //out = new PrintWriter("output.out");
    	out = new PrintWriter(System.out);
        sc = new StringTokenizer("");
        
        TaskD solver = new TaskD();
        solver.solve();
        
        br.close();
        out.close();
        //System.out.println("Finished");
    }    
    
    static class TaskD {
        public void solve() throws IOException {
        	int n = nxtInt();
        	
        	char[] num = new char[10];
        	for (int i = 0; i < 10; i++)
        		num[i] = 's';
        	
        	for (int i = 0; i < n; i++) {
        		String str = nxtTok();      		
        		
        		char[] arg = toBin(nxtInt());
        		
        		if (str.equals("&")) {
        			for (int j = 0; j < 10; j++) {
        				if (arg[j] == '0')
        					num[j] = '0';
        			}
        		}
        		else if (str.equals("|")) {
        			for (int j = 0; j < 10; j++) {
        				if (arg[j] == '1')
        					num[j] = '1';
        			}
        		}
        		else if (str.equals("^")) {
        			for (int j = 0; j < 10; j++) {
        				if (arg[j] == '1') {
        					if (num[j] == '1')
        						num[j] = '0';
        					else if (num[j] == '0')
        						num[j] = '1';
        					if (num[j] == 's')
        						num[j] = 'i';
        					else if (num[j] == 'i')
        						num[j] = 's';
        				}
        			}
        		}
        	}
        	
        	/***** XOR *****************/
        	boolean XOR = false;
        	int XORnumber = 0;
        	for (int i = 0; i < 10; i++) {
        		if (num [i] == 'i') {
        			XORnumber += Math.pow(2,  i);
        			XOR = true;
        		}
        	}
        	
        	/***** OR *****************/
        	boolean OR = false;
        	int ORnumber = 0;
        	for (int i = 0; i < 10; i++) {
        		if (num [i] == '1') {
        			ORnumber += Math.pow(2,  i);
        			OR = true;
        		}
        	}
        	
        	/***** AND *****************/
        	boolean AND = false;
        	int ANDnumber = 1023;
        	for (int i = 0; i < 10; i++) {
        		if (num [i] == '0') {
        			ANDnumber -= Math.pow(2,  i);
        			AND = true;
        		}
        	}
        	
        	int ops = 0;
        	if (XOR)
        		ops++;
        	if (OR)
        		ops++;
        	if (AND)
        		ops++;
        	
        	out.println(ops);
        	
        	if (XOR)
        		out.println("^ " + XORnumber);
        	if (OR)
        		out.println("| " + ORnumber);
        	if (AND)
        		out.println("& " + ANDnumber);
        }
        
        char[] toBin(int n) {
        	char[] num = new char[10];
        	
        	int index = 0;
        	
        	while (n > 0) {
        		if (n % 2 == 0)
        			num[index++] = '0';
        		else
        			num[index++] = '1';
        		
        		n = n / 2;
        	}
        	
        	for (int i = index; i < 10; i++)
        		num[i] = '0';
        	
        	return num;
        }

        class Trie {
            Node root;

            Trie() {
                root = new Node();
            }

            void add(long x) {

                Node cur = root;
                // int depth = 0;
                while (x > 0) {
                    int ls = (int)(x % 10);
                    x /= 10;
                    cur.cnt[ls]++;
                    if (cur.nodes[ls] == null)
                        cur.nodes[ls] = new Node();
                    cur = cur.nodes[ls];
                }
            }

            void sub(long x) {

                Node cur = root;
                while (x > 0) {
                    int ls = (int)(x % 10);
                    x /= 10;
                    cur.cnt[ls]--;
                    cur = cur.nodes[ls];
                }
            }

            long[] getcnt(long x) {

                int res = 0;
                int prev = 0;
                int depth = 0;
                Node cur = root;

                while (x > 0 && depth < 10) {
                    int ls = (int)(x % 10);
                    x /= 10;
                    res = cur.cnt[9 - ls];
                    if (res != 0) {
                        depth++;
                        prev = res;
                        cur = cur.nodes[9 - ls];
                    } else
                        break;
                }

                return new long[]{depth, prev};
            }

        }

        class Node {
            Node[] nodes;
            int[] cnt;

            Node() {
                nodes = new Node[10];
                cnt = new int[10];
            }

        }

    }

    static String nxtTok() throws IOException {
        while (!sc.hasMoreTokens()) {
            String s = br.readLine();
            
            if (s == null) {
                return null;
            }
            sc = new StringTokenizer(s.trim());
        }
        return sc.nextToken();
    }

    static int nxtInt() throws IOException {
        return Integer.parseInt(nxtTok());
    }

    static long nxtLng() throws IOException {
        return Long.parseLong(nxtTok());
    }

    static double nxtDbl() throws IOException {
        return Double.parseDouble(nxtTok());
    }

    static int[] nxtIntArr(int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nxtInt();
        }
        return a;
    }

    static long[] nxtLngArr(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nxtLng();
        }
        return a;
    }

    static char[] nxtCharArr() throws IOException {
        return nxtTok().toCharArray();
    }
    
    static int getMin(int arr[], int count)
    {
    	int min = arr[0];
    	for (int i = 1; i < count; i++)
    		if (arr[i] < min)
    			min = arr[i];

    	return min;
    }

    static int getMax(int arr[], int count)
    {
    	int max = arr[0];
    	for (int i = 1; i < count; i++)
    		if (arr[i] > max)
    			max = arr[i];

    	return max;
    }

    static void sortAsc(int arr[], int count)
    {
        int temp;

        for (int i = 0; i < count - 1; i++)
        {
            for (int j = i + 1; j < count; j++)
            {
                if (arr[i] > arr[j])
                {
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }

    static void sortDesc(int arr[], int count)
    {
        int temp;

        for (int i = 0; i < count - 1; i++)
        {
            for (int j = i + 1; j < count; j++)
            {
                if (arr[i] < arr[j])
                {
                    temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }
}