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
 *
 * @author zcw
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] bit = new int[10];
            for (int i = 0; i < 10; i++) bit[i] = 2;
            for (int i = 1; i < n; i++) {
                String op = in.next();
                int k = in.nextInt();
                if (op.equals("|")) {
                    for (int j = 0; j < 10; j++)
                        if ((k >> j & 1) != 0) {
                            bit[j] = 1;
                        }
                } else if (op.equals("&")) {
                    for (int j = 0; j < 10; j++)
                        if ((k >> j & 1) == 0) {
                            bit[j] = 0;
                        }
                } else if (op.equals("^")) {
                    for (int j = 0; j < 10; j++) {
                        if (bit[j] == 0 || bit[j] == 1) {
                            bit[j] ^= k >> j;
                        } else {
                            bit[j] = 5 - bit[j];
                        }
                    }
                }
            }
            out.println(3);
            out.print("| ");
            int ans = 0;
            for (int i = 0; i < 10; i++)
                if (bit[i] == 1) {
                    ans |= 1 << i;
                }
            out.println(ans);
            out.print("& ");
            ans = (1 << 10) - 1;
            for (int i = 0; i < 10; i++)
                if (bit[i] == 0) {
                    ans ^= 1 << i;
                }
            out.println(ans);
            out.print("^ ");
            ans = 0;
            for (int i = 0; i < 10; i++)
                if (bit[i] == 3) {
                    ans ^= 1 << i;
                }
            out.println(ans);
        }

    }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            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());
        }

    }
}

