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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {
    public static void main(String []args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver=new Task();
        solver.solve(1,in,out);
        out.close();
    }
    static class Task{
        public void solve(int testnumber,InputReader in,PrintWriter out){
            int n = in.nextInt();
            int [] bits = new int[]{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
            int [] temp = new int[10];
            for(int i=0;i<n;i++){
                String s = in.nextToken();
                int x = in.nextInt();
                int h = 9;
                while(x!=0){
                    temp[h--] = x % 2;
                    x /= 2;
                }
                while(h >= 0){
                    temp[h--] = 0;
                }
                if(s.charAt(0) == '&'){
                    for(int j = 0 ; j < 10 ; j++){
                        if(temp[j] == 0){
                            bits[j] = 0;
                        }
                    }
                } else if(s.charAt(0) == '|'){
                    for(int j = 0 ; j < 10 ; j++){
                        if(temp[j] == 1){
                            bits[j] = 1;
                        }
                    }
                } else {
                    for(int j = 0 ; j < 10 ; j++){
                        if(bits[j] == -1){
                            continue;
                        } else {
                            bits[j] = bits[j] ^ temp[j];
                        }
                    }
                }
            }
            int y = 0;
            for(int i = 0 ; i < 10 ; i++){
                if(bits[i] == -1) {
                    y++;
                }
            }
            if(y == 10){
                out.println(0);
            } else {
                for(int i = 0 ; i < 10 ; i++){
                    if(bits[i] == -1){
                        temp[i] = 1;
                    } else if(bits[i] == 0){
                        temp[i] = 0;
                    } else {
                        temp[i] = 0;
                    }
                }
                int sum = 0;
                for(int i = 0 ; i < 10 ; i++){
                    sum += (temp[i]*power_p(2,9-i));
                }
                out.println("2");
                out.println("& "+sum);
                sum = 0;
                for(int i = 0 ; i < 10 ; i++){
                    if(bits[i] == -1){
                        temp[i] = 0;
                    } else if(bits[i] == 0){
                        temp[i] = 0;
                    } else if(bits[i] == 1){
                        temp[i] = 1;
                    }
                }
                for(int i = 0 ; i < 10 ; i++){
                    sum += (temp[i]*power_p(2,9-i));
                }
                out.println("| "+sum);
            }
        }

        private int power_p(int x, int i1) {
            int t = 1;
            for(int i = 1 ; i <= i1 ; i++){
                t *= x;
            }
            return t;
        }
    }
    static class InputReader{
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        private int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public String nextToken() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c-'0';
                c = next();
            } while (!isSpaceChar(c));
            return res*sgn;
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}
