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

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int n=Integer.parseInt(bu.readLine());
        int b[][]=new int[10][2],i,j;
        for(i=0;i<10;i++) b[i][1]=1;    //our starting value

        for(i=0;i<n;i++)
        {
            String s[]=bu.readLine().split(" ");
            int x=Integer.parseInt(s[1]);
            if(s[0].equals("|"))
            for(j=0;j<10;j++)
            {
                b[j][0]|=(x>>j)&1;
                b[j][1]|=(x>>j)&1;
            }
            else if(s[0].equals("^"))
            for(j=0;j<10;j++)
            {
                b[j][0]^=(x>>j)&1;
                b[j][1]^=(x>>j)&1;
            }
            else
            for(j=0;j<10;j++)
            {
                b[j][0]&=(x>>j)&1;
                b[j][1]&=(x>>j)&1;
            }
        }

        int and=0,or=0,xor=0;
        for(i=0;i<10;i++)
        if(b[i][0]==b[i][1])
        {
            if(b[i][0]==1)  //both places have 1 irrespective of starting, this can be made possible with or
            or+=1<<i;
            //else both places have 0 irrespective of starting, this means we have an and 0 here
        }
        else
        {
            if(b[i][0]==1)  //this means 0->1 and 1->0, thus xor happened
            xor+=1<<i;
            else //0 stayed 0 and 1 stayed 1, and happened
            and+=1<<i;
        }
        sb.append("3\n");
        sb.append("& "+and+"\n");
        sb.append("^ "+xor+"\n");
        sb.append("| "+or+"\n");
        System.out.print(sb);
    }
}
