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

/**
 * Created by Aminul on 10/26/2017.
 */

import java.io.*;
import java.util.*;

public class C {
    public static void main(String[] args) throws Exception {
        FastReader in = new FastReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = in.nextInt();
        int sym[] = new int[n], num[] = new int[n];
        boolean finalized[] = new boolean[10];
        for(int i = 0; i < n; i++){
            char c = in.nextChar();
            int x = in.nextInt();
            sym[i] = c;
            num[i] = x;
        }

        //int xor[] = new int[10];
        int bits[] = new int[10];
        int cnt[] = new int[10];
        for(int i = n-1; i >= 0; i--){
            char[] s = toBinString(num[i]);
            for(int k = 0; k < 10; k++){
                if(finalized[k]) continue;
                else{
                    if(sym[i] == '|' && s[k] == '1'){
                        bits[k] = (1 + bits[k]) % 2;
                        finalized[k] = true;
                    }
                    else if(sym[i] == '&' && s[k] == '0'){
                        bits[k] = (bits[k]) % 2;
                        finalized[k] = true;
                    }
                    else if(sym[i] == '^' && s[k] == '1'){
                        bits[k] = (bits[k]+1) % 2;
                        cnt[k]++;
                    }
                }
            }
        }

        //debug(bits);
       // debug(cnt);
       // debug(finalized);

        String and = "", or = "", xor = "";
        for(int i = 0; i < 10; i++){
            if(finalized[i] && bits[i] == 0) and += "0";
            else and += "1";

            if(finalized[i] && bits[i] == 1) or += "1";
            else or += "0";

            if(bits[i] == 1 && !finalized[i]) xor += "1";
            else xor += "0";

        }

        pw.println(3);
        pw.println("| "+Integer.parseInt(or, 2));
        pw.println("& "+Integer.parseInt(and, 2));
        pw.println("^ "+Integer.parseInt(xor, 2));


        pw.close();
    }

    static char[] toBinString(int n){
        String s = Integer.toBinaryString(n);
        while(s.length() < 10) s = "0"+s;
        return s.toCharArray();
    }

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class FastReader {
        InputStream is;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0, ptrbuf = 0;
        static final int ints[] = new int[128];

        public FastReader(InputStream is) {
            for (int i = '0'; i <= '9'; i++) ints[i] = i - '0';
            this.is = is;
        }

        public int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = is.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public boolean isSpaceChar(int c) {
            return !(c >= 33 && c <= 126);
        }

        public int skip() {
            int b;
            while ((b = readByte()) != -1 && isSpaceChar(b)) ;
            return b;
        }

        public String next() {
            int b = skip();
            StringBuilder sb = new StringBuilder();
            while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = (num << 3) + (num << 1) + ints[b];
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
        public char nextChar() {
            return (char)skip();
        }

        public char[] next(int n) {
            char[] buf = new char[n];
            int b = skip(), p = 0;
            while (p < n && !(isSpaceChar(b))) {
                buf[p++] = (char) b;
                b = readByte();
            }
            return n == p ? buf : Arrays.copyOf(buf, p);
        }

        /*private char buff[] = new char[1005];
        public char[] nextCharArray(){
            int b = skip(), p = 0;
            while(!(isSpaceChar(b))){
                buff[p++] = (char)b;
                b = readByte();
            }
            return Arrays.copyOf(buff, p);
        }*/
    }
}