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

public class Main {
    static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;


    void solve() throws IOException {
        int max = 1023;
        int min = 0;
        int n = readInt();
        int val = 0;
        while (n-- > 0) {
            String str = readString();
            val = readInt();
            if (str.charAt(0) == '|') {
                max |= val;
                min |= val;
            }
            if (str.charAt(0) == '&') {
                max &= val;
                min &= val;
            }
            if (str.charAt(0) == '^') {
                max ^= val;
                min ^= val;
            }
        }
        int[][] arr = new int[10][2];
        for (int i = 0; i < 10; i++) {
            arr[i][0] = min % 2;
            min /= 2;
        }
        for (int i = 0; i < 10; i++) {
            arr[i][1] = max % 2;
            max /= 2;
        }
        //or xor and
        int answer[][] = new int[10][3];
        for (int i = 0; i < 10; i++) {
            if(arr[i][0]==0&&arr[i][1]==0) continue;
            if(arr[i][0]==1&&arr[i][1]==0){
                answer[i][1]++;
                answer[i][2]++;
            }
            if(arr[i][0]==1&&arr[i][1]==1){
                answer[i][2]++;
                answer[i][0]++;
            }
            if(arr[i][0]==0&&arr[i][1]==1){
                answer[i][2]++;
            }
        }
        int xor =0;
        int or=0;
        int and =0;
        for (int i =0;i<10;i++){
            or+=answer[i][0]*Math.pow(2,i);
        }
        for (int i =0;i<10;i++){
            xor+=answer[i][1]*Math.pow(2,i);
        }
        for (int i =0;i<10;i++){
            and+=answer[i][2]*Math.pow(2,i);
        }
        out.println(3);
        out.println("& "+and);
        out.println("| "+or);
        out.println("^ "+xor);
    }

    int minInt(int... values) {
        int min = Integer.MAX_VALUE;
        for (int value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    int maxInt(int... values) {
        int max = Integer.MIN_VALUE;
        for (int value : values) {
            max = Math.max(max, value);
        }
        return max;
    }

    long minLong(long... values) {
        long min = Long.MAX_VALUE;
        for (long value : values) {
            min = Math.min(min, value);
        }
        return min;
    }

    long maxLong(long... values) {
        long min = Long.MIN_VALUE;
        for (long value : values) {
            min = Math.max(min, value);
        }
        return min;
    }

    public static void main(String[] args) {
        new Main().run();
    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;


    void init() 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("");

    }

    void run() {
        try {
            long timeStart = System.currentTimeMillis();

            init();
            solve();

            out.close();

            long timeEnd = System.currentTimeMillis();
            System.err.println("Time = " + (timeEnd - timeStart) + " COMPILED");
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((-memoryTotal + memoryFree) >> 10) + " KB");
    }

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

    String delimiter = " ";

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

            tok = new StringTokenizer(nextLine);
        }

        return tok.nextToken(delimiter);
    }

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

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }


    void sortArrayInteger(int[] a) {
        Integer arr[] = new Integer[a.length];
        for (int i = 0; i < a.length; i++) {
            arr[i] = a[i];
        }
        Arrays.sort(arr);
        for (int i = 0; i < a.length; i++) {
            a[i] = arr[i];
        }
    }

}