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.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.BitSet;

public class C {

    private static State[] bitStates;
    private static int MAX_INDEX = 9;

    public static void main(String[] args) throws Exception {
        bitStates = new State[MAX_INDEX + 1];
        Arrays.fill(bitStates, State.DEFAULT);

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());

        for (int i=0; i<N; i++) {
            String s = br.readLine();
            String[] tokens = s.split(" ");
            char operation = tokens[0].charAt(0);
            int constant = Integer.parseInt(tokens[1]);
            Command command = new Command(operation, constant, MAX_INDEX);
            command.apply(bitStates);
        }

        // Now let us construct the final short program.
        // Everything that is set, needs to be OR-ed.
        BitSet OR = BitSet.valueOf(new long[]{0});
        OR.clear();
        for (int i=0; i<=MAX_INDEX; i++) {
            if (bitStates[i] == State.SET) {
                OR.set(i);
            }
        }
        int orConstant = 0;
        if (OR.toLongArray().length != 0) {
            orConstant = (int) OR.toLongArray()[0];
        }

        // Everything that is cleared, needs to be AND-ed.
        BitSet AND =  BitSet.valueOf(new long[]{1023});
        for (int i=0; i<=MAX_INDEX; i++) {
            if (bitStates[i] == State.CLEAR) {
                AND.clear(i);
            }
        }
        int andConstant = 1023;
        if (AND.toLongArray().length != 0) {
            andConstant = (int) AND.toLongArray()[0];
        }

        // Everything that is toggled, needs to be XOR-ed.
        BitSet XOR =  BitSet.valueOf(new long[]{0});
        for (int i=0; i<=MAX_INDEX; i++) {
            if (bitStates[i] == State.TOGGLE) {
                XOR.set(i);
            }
        }
        int xorConstant = 0;
        if (XOR.toLongArray().length != 0) {
            xorConstant = (int) XOR.toLongArray()[0];
        }

        System.out.println(3);
        System.out.println("| " + orConstant);
        System.out.println("& " + andConstant);
        System.out.println("^ " + xorConstant);
    }

}

enum State {
    DEFAULT, SET, CLEAR, TOGGLE;
}

class Command {
    enum Operation {
        AND, OR, XOR
    }

    private Operation operation;
    private BitSet constant;
    private int MAX_INDEX;

    public Command(char operator, int constant, int maxIndex) {
        switch (operator) {
            case '&':   this.operation = Operation.AND;
                        break;
            case '|':   this.operation = Operation.OR;
                break;
            case '^':   this.operation = Operation.XOR;
                break;
        }
        this.constant = BitSet.valueOf(new long[]{constant});
        this.MAX_INDEX = maxIndex;
    }

    public void apply(State[] states) {
        if (operation == Operation.OR) {
            applyOr(states);
        } else if (operation == Operation.AND) {
            applyAnd(states);
        } else if (operation == Operation.XOR) {
            applyXor(states);
        }
    }

    private void applyOr(State[] states) {
        for (int i = constant.nextSetBit(0); i >= 0; i = constant.nextSetBit(i+1)) {
            if (i > MAX_INDEX) {
                break;
            }
            states[i] = State.SET;
        }
    }

    private void applyAnd(State[] states) {
        for (int i = constant.nextClearBit(0); i >= 0; i = constant.nextClearBit(i+1)) {
            if (i > MAX_INDEX) {
                break;
            }
            states[i] = State.CLEAR;
        }
    }

    private void applyXor(State[] states) {
        for (int i = constant.nextSetBit(0); i >= 0; i = constant.nextSetBit(i+1)) {
            if (i > MAX_INDEX) {
                break;
            }
            if (states[i] == State.DEFAULT) {
                states[i] = State.TOGGLE;
            } else if (states[i] == State.SET) {
                states[i] = State.CLEAR;
            } else if (states[i] == State.CLEAR) {
                states[i] = State.SET;
            } else if (states[i] == State.TOGGLE) {
                states[i] = State.DEFAULT;
            }
        }
    }

}