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;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Operation[] operations = new Operation[n];
            for (int i = 0; i < n; ++i) {
                operations[i] = new Operation(in.next().charAt(0), in.nextInt());
            }
            Operation[] ans = new Operation[4];
            ans[0] = new Operation('&', 1023);
            ans[1] = new Operation('|', 0); // id func in fact
            ans[2] = new Operation('^', 0);
            ans[3] = new Operation('|', 0);
            for (int bit = 0; bit < 10; ++bit) {
                int[] fRes = {0, 1 << bit};
                for (int bitVal = 0; bitVal < 2; ++bitVal) {
                    for (int i = 0; i < n; ++i) {
                        fRes[bitVal] = operations[i].apply(fRes[bitVal]);
                    }
                    if ((fRes[bitVal] & (1 << bit)) > 0) {
                        fRes[bitVal] = 1;
                    } else {
                        fRes[bitVal] = 0;
                    }
                }
                if (fRes[0] == 0 && fRes[1] == 0) {
                    ans[0].value &= ~(1 << bit);
                } else if (fRes[0] == 0 && fRes[1] == 1) {
                    ans[1].value += 0;
                } else if (fRes[0] == 1 && fRes[1] == 0) {
                    ans[2].value |= (1 << bit);
                } else {
                    ans[3].value |= (1 << bit);
                }
            }
            out.println(ans.length);
            for (Operation op : ans) {
                out.println(op.type + " " + op.value);
            }
        }

        class Operation {
            char type;
            int value;

            public Operation(char type, int value) {
                this.type = type;
                this.value = value;
            }

            public int apply(int x) {
                if (type == '|') {
                    return x | value;
                }
                if (type == '&') {
                    return x & value;
                }
                return x ^ value;
            }

        }

    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 65536 / 2);
            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 int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

