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.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.io.IOException;
import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {

        File file = new File("in.txt");
        File fileOut = new File("out.txt");
        InputStream inputStream = null;
        OutputStream outputStream = null;
        // try {inputStream= new FileInputStream(file);} catch (FileNotFoundException ex){return;};
//        try {outputStream= new FileOutputStream(fileOut);} catch (FileNotFoundException ex){return;};
        inputStream = System.in;
        outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }


}

class Task {

    List<Integer> opVals;
    List<Character> op;
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        Integer n = in.nextInt();
        opVals = new ArrayList<>(n);
        op = new ArrayList<>(n);
        for(int i=0; i<n; i++){
            op.add(in.next().charAt(0));
            opVals.add(in.nextInt());
        }

        Set<Integer> alwaysZero = new HashSet<>();
        Set<Integer> alwaysOne = new HashSet<>();
        Set<Integer> flip = new HashSet<>();
        for(int i=0; i<10; i++){
            Boolean evalZero = evaluateBit(false, i);
            Boolean evalOne = evaluateBit(true, i);
            if(!evalZero && !evalOne){
                alwaysZero.add(i);
            }
            else if(evalZero && evalOne){
                alwaysOne.add(i);
            }
            else if(evalZero && !evalOne){
                flip.add(i);
            }
        }

        Set<Integer> complAlwaysZero = new HashSet<>();
        for(int i=0; i<10; i++){
            if(!alwaysZero.contains(i)){
                complAlwaysZero.add(i);
            }
        }
        out.println(3);
        out.println("& " + formNumber(complAlwaysZero));
        out.println("| " + formNumber(alwaysOne));
        out.println("^ " + formNumber(flip));



//        out.println("Zero: " + alwaysZero);
//        out.println("One "  + alwaysOne);
//        out.println("Flip: " + flip);
    }

    public Integer formNumber(Set<Integer> bitSet){
        Integer val = 0;
        for(Integer i : bitSet){
            Integer v = 1 << i;
            val += v;
        }
        return val;
    }

    public Boolean evaluateBit(Boolean bitVal, Integer bit){
        Integer val = 0;
        if(bitVal) {
            val = 1 << bit;
        }

        for(int i=0; i<op.size(); i++){
            Character o = op.get(i);
            Integer v = opVals.get(i);
            if(o == '|'){
                val = val | v;
            }
            else if(o == '^'){
                val = val ^ v;
            }
            else if (o == '&'){
                val = val & v;
            }
        }

        return (val & (1<<bit)) > 0;

    }




}



class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine(){
        try {
            return reader.readLine();
        } catch (IOException e){
            throw new RuntimeException(e);
        }
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
    public long nextLong() { return Long.parseLong(next()); }

}



class Pair<F, S> {
    public final F first;
    public final S second;




    public Pair(F first, S second) {
        this.first = first;
        this.second = second;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Pair)) {
            return false;
        }
        Pair<?, ?> p = (Pair<?, ?>) o;
        return Objects.equals(p.first, first) && Objects.equals(p.second, second);
    }

    @Override
    public int hashCode() {
        return (first == null ? 0 : first.hashCode()) ^ (second == null ? 0 : second.hashCode());
    }

    @Override
    public String toString() {
        return "(" + first + ", " + second + ')';
    }
}

class IntPair extends Pair<Integer, Integer>{
    public IntPair(Integer first, Integer second){
        super(first, second);
    }
}