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

public class Solution {

    public static void solve(InputReader in, PrintWriter out, DebugWriter debug) throws IOException {
        int n = in.nextInt();
        char[] number = {'x','x','x','x','x','x','x','x','x','x'};// y = -x

        for (int i=0; i<n; i++){
            String operation = in.next();
            String binary = Integer.toBinaryString(in.nextInt());
            while (binary.length() < number.length) binary = "0"+binary;

            for (int pos=0; pos<number.length; pos++){
                char symbolInNumber = number[pos];
                char symbolInBinary = binary.charAt(pos);
                char symbolResult = ' ';

                if (operation.charAt(0) == '|'){
                    if (symbolInNumber == '0' && symbolInBinary == '0') symbolResult = '0';
                    if (symbolInNumber == '1' && symbolInBinary == '0') symbolResult = '1';
                    if (symbolInNumber == 'x' && symbolInBinary == '0') symbolResult = 'x';
                    if (symbolInNumber == 'y' && symbolInBinary == '0') symbolResult = 'y';
                    if (symbolInNumber == '0' && symbolInBinary == '1') symbolResult = '1';
                    if (symbolInNumber == '1' && symbolInBinary == '1') symbolResult = '1';
                    if (symbolInNumber == 'x' && symbolInBinary == '1') symbolResult = '1';
                    if (symbolInNumber == 'y' && symbolInBinary == '1') symbolResult = '1';
                }

                if (operation.charAt(0) == '&'){
                    if (symbolInNumber == '0' && symbolInBinary == '0') symbolResult = '0';
                    if (symbolInNumber == '1' && symbolInBinary == '0') symbolResult = '0';
                    if (symbolInNumber == 'x' && symbolInBinary == '0') symbolResult = '0';
                    if (symbolInNumber == 'y' && symbolInBinary == '0') symbolResult = '0';
                    if (symbolInNumber == '0' && symbolInBinary == '1') symbolResult = '0';
                    if (symbolInNumber == '1' && symbolInBinary == '1') symbolResult = '1';
                    if (symbolInNumber == 'x' && symbolInBinary == '1') symbolResult = 'x';
                    if (symbolInNumber == 'y' && symbolInBinary == '1') symbolResult = 'y';
                }

                if (operation.charAt(0) == '^'){
                    if (symbolInNumber == '0' && symbolInBinary == '0') symbolResult = '0';
                    if (symbolInNumber == '1' && symbolInBinary == '0') symbolResult = '1';
                    if (symbolInNumber == 'x' && symbolInBinary == '0') symbolResult = 'x';
                    if (symbolInNumber == 'y' && symbolInBinary == '0') symbolResult = 'y';
                    if (symbolInNumber == '0' && symbolInBinary == '1') symbolResult = '1';
                    if (symbolInNumber == '1' && symbolInBinary == '1') symbolResult = '0';
                    if (symbolInNumber == 'x' && symbolInBinary == '1') symbolResult = 'y';
                    if (symbolInNumber == 'y' && symbolInBinary == '1') symbolResult = 'x';
                }

                number[pos] = symbolResult;
            }
        }

        String ans1Str = "";
        for (int i=0; i<number.length; i++) if (number[i] == '0') ans1Str+="0"; else ans1Str+="1";

        String ans2Str = "";
        for (int i=0; i<number.length; i++) if (number[i] == '1') ans2Str+="1"; else ans2Str+="0";

        String ans3Str = "";
        for (int i=0; i<number.length; i++) if (number[i] == 'y') ans3Str+="1"; else ans3Str+="0";

        out.println(3);
        out.print("& ");
        out.println(Integer.parseInt(ans1Str,2));
        out.print("| ");
        out.println(Integer.parseInt(ans2Str,2));
        out.print("^ ");
        out.println(Integer.parseInt(ans3Str,2));
    }

    public static final String NAME = "";

    public static void main(String[] args) throws IOException{
        InputReader in;
        PrintWriter out;
        DebugWriter debug;

        if (args.length > 0 && args[0].equals("file")) {
            in = new InputReader(new BufferedReader(new FileReader("input.txt")));
            out = new PrintWriter(new FileWriter("output.txt"));
            debug = new DebugWriter(true);

            int sampleNumber = 1;
            do {
                String nextSample = "Sample #" + sampleNumber++ + ": ";
                out.println(nextSample);
                debug.println(nextSample);

                solve(in, out, debug);

                out.println("");
                debug.println("");
            } while (in.reader.readLine() != null);
        } else {
            if (NAME.length() > 0) {
                in = new InputReader(new BufferedReader(new FileReader(NAME + ".in")));
                out = new PrintWriter(new FileWriter(NAME + ".out"));
            } else {
                in = new InputReader(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            debug = new DebugWriter(false);
            solve(in, out, debug);
        }

        in.reader.close();
        out.close();
    }

    public static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(BufferedReader reader) {
            this.reader = reader;
            tokenizer = null;
        }

        public String next() throws IOException{
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }

            return tokenizer.nextToken();
        }

        public int nextInt() throws IOException{
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) throws IOException{
            int[] array = new int[n];
            for (int i=0; i<n; i++){
                array[i] = nextInt();
            }

            return array;
        }
    }

    public static class DebugWriter {
        public boolean enable;

        public DebugWriter(boolean enable){
            this.enable = enable;
        }

        public void print(Object o){
            if (enable) System.out.print(o);
        }

        public void println(Object o){
            if (enable) System.out.println(o);
        }
    }

}