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.math.BigInteger;
import java.util.*;


public class Main {

    public static boolean debug = false;

    static  class Op{
        public char operation;
        public int num;
    }


    public static void doOp(int[] num1 ,int num2, char op)
    {
        for(int i = 0; i<num1.length ; i++)
        {
            int b = num2%2;
            if(op == '&' && b ==0)
            {
                num1[i] = 0;

            }
            if(op == '|' && b == 1)
            {
                num1[i] = 1;
            }

            if(op == '^' && b ==1)
            {
                    num1[i] *= (-1);

            }
            num2 /=2;
        }

    }

    public static boolean matchNum(int[] num1 , int[] num2)
    {
        for(int i = 0 ; i<num1.length ; i++)
        {
            if(num1[i] != num2[i])
            {
                return false;
            }
        }
        return true;
    }




    public static void main(String[] args) throws FileNotFoundException {
        TimerX.start();


        Scanner scanner = debug ? new Scanner(new File("sample.in")) : new Scanner(System.in);

        int n = scanner.nextInt();

        Op[] ops = new Op[n];
        int[] finalOutput = new int[10];
        int[] initialOutput = new int[10];
        for(int i = 0 ; i<finalOutput.length;i++)
        {
            finalOutput[i] = 9;
            initialOutput[i] = 9;
        }

        for(int i = 0 ;i<n;i++)
        {

            ops[i] = new Op() ;
            ops[i].operation = scanner.next().charAt(0);;
            ops[i].num = scanner.nextInt();
            doOp(finalOutput,ops[i].num,ops[i].operation);
        }





        Stack<int[]> states = new Stack<int[]>();
        Stack<ArrayList<Integer>> counts = new Stack<ArrayList<Integer>>();
        Stack<Integer> lastOp = new Stack<Integer>();
        states.push(initialOutput);
        counts.push(new ArrayList<Integer>());
        lastOp.push(-1);
        while(states.size()>0)
        {
            int last = lastOp.pop();
            last++;
            int[] currentState = states.pop();
            ArrayList<Integer> countX = counts.pop();

            if(countX.size()>5)
            {
                continue;
            }


            if(matchNum(currentState,finalOutput))
            {
                System.out.println(countX.size());
                for(int i : countX)
                {
                    System.out.println(ops[i].operation+" "+ops[i].num);
                }
                return;
            }
            if(last == n)
            {
                continue;

            }



            states.push(currentState);
            counts.push(countX);
            lastOp.push(last);

            doOp(currentState,ops[last].num,ops[last].operation);
            countX.add(last);
            lastOp.push(last);
            states.push(currentState);
            counts.push(countX);

        }








        TimerX.end();
    }


    static class Utility {
        public static int getDigitSum(int n) {
            int sum = 0;
            while (n > 0) {
                sum += n % 10;
                n /= 10;
            }

            return sum;

        }

        public static void printArr2D(int[][] x) {
            for (int i = 0; i < x.length; i++) {
                for (int j = 0; j < x[i].length; j++) {
                    System.out.print(x[i][j] + " ");
                }
                System.out.println();
            }

        }

    }

    static class TimerX {
        static long startTimer;

        public static void start() {
            startTimer = System.currentTimeMillis();
        }

        public static void end() {
            if (debug) {
                System.out.println("\nExecution time " + timeToString(System.currentTimeMillis() - startTimer));
            }
        }

        public static String timeToString(long diff) {
            long sec = (diff / 1000) % 60;
            long min = (diff / 1000) / 60;

            return min + " minutes and " + sec + " seconds";


        }

    }


}

