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.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.lang.Math.abs;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.round;
import static java.util.Arrays.copyOf;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;
import static java.util.Collections.reverseOrder;
import static java.util.Collections.sort;
import static java.util.Comparator.comparing;

public class Main {
    FastScanner in;
    PrintWriter out;

    private void solve() throws IOException {
        int n = in.nextInt();
        String[] s;
        StringBuilder sb = new StringBuilder();
        int[] bit = new int[10];
        fill(bit, 2);

        for (int i = 0; i < n; i++) {
            s = in.nextLine().split(" ");

            sb.delete(0, sb.length());
            sb.append(Integer.toBinaryString(Integer.parseInt(s[1])));
            sb.reverse();
            while (sb.length() < bit.length)
                sb.append("0");
            sb.reverse();
            s[1] = sb.toString();

            switch (s[0]) {
                case "^":
                    for (int j = 0; j < s[1].length(); j++)
                        if (s[1].charAt(j) == '1')
                            bit[j] = -bit[j];
                    break;
                case "|":
                    for (int j = 0; j < s[1].length(); j++)
                        if (s[1].charAt(j) == '1')
                            bit[j] = 1;
                    break;
                case "&":
                    for (int j = 0; j < s[1].length(); j++)
                        if (s[1].charAt(j) == '0')
                            bit[j] = -1;
                    break;
            }
        }

        out.println(3);

        int and = 0;
        for (int i : bit) {
            if (i != -1)
                and++;
            and *= 2;
        }
        out.println("& " + and / 2);

        int or = 0;
        for (int i : bit) {
            if (i == 1)
                or++;
            or *= 2;
        }
        out.println("| " + or / 2);

        int xor = 0;
        for (int i : bit) {
            if (i == -2)
                xor++;
            xor *= 2;
        }
        out.println("^ " + xor / 2);
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }
    }

    private void run() throws IOException {
        in = new FastScanner(System.in); // new FastScanner(new FileInputStream("input.txt"));
        out = new PrintWriter(System.out); // new PrintWriter(new FileOutputStream("output.txt"));

        solve();

        out.flush();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}