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.util.*;

import static java.lang.Math.*;
import static java.util.Collections.*;
import static java.util.Arrays.*;

public class Main {
    /**
     * Solution
     */
    static class Solution {
        public void solve(Scanner in, PrintWriter out) {
            int n, k, t1 = 0, t2 = 1023;
            char c;
            n = in.nextInt();
            for (int i = 0; i < n; i++) {
                c = in.next().charAt(0);
                k = in.nextInt();
                if(c == '|') {
                    t1 |= k;
                    t2 |= k;
                } else if(c == '^') {
                    t1 ^= k;
                    t2 ^= k;
                } else {
                    t1 &= k;
                    t2 &= k;
                }
            }
            int xor = t1 ^ t2;
            out.print(2 + "\n");
            out.print("& " + xor + "\n");
            out.print("^ " + t1 + "\n");
        }
    }

    public static void main(String[] args) {
        boolean onlineJudge = System.getProperty("ONLINE_JUDGE") != null;
        if (onlineJudge) {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            Scanner inputReader = new Scanner(inputStream);
            PrintWriter printWriter = new PrintWriter(outputStream);
            Solution solution = new Solution();
            solution.solve(inputReader, printWriter);
            printWriter.close();
        } else {
            InputStream inputStream = null;
            try {
                inputStream = new FileInputStream("./src/com/company/Files/in.txt");
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            OutputStream outputStream = System.out;
            Scanner inputReader = new Scanner(inputStream);
            PrintWriter printWriter = new PrintWriter(outputStream);
            Solution solution = new Solution();
            byte test = 1;
            while (true) {
                try {
                    if (!inputReader.bufferedReader.ready()) break;
                } catch (IOException e) {
                    e.printStackTrace();
                }
                printWriter.print("Test#" + test + ":\n");
                solution.solve(inputReader, printWriter);
                printWriter.print("\n\n");
                test++;
            }
            printWriter.close();
        }
    }
    private static class Scanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        private Scanner(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
            stringTokenizer = null;
        }

        public String next() {
            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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


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

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

    }
}