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 lab {
    public static void main(String[] args) throws IOException {
        Ifmo ifmo = new Ifmo();
    }
}
class Ifmo {
    int[]  pows;
    int n, t, s, m;
    ArrayList<Edge> e;
    ArrayList<Integer> g[];
    int[] q, d, ptr;
    int INF = 1000000000;
    Ifmo() throws IOException {
        //FScanner fs = new FScanner(new FileReader("kbest.in"));
        FScanner fs = new FScanner(new InputStreamReader(System.in));
        //PrintWriter pw = new PrintWriter(new FileWriter("kbest.out"));
        PrintWriter pw = new PrintWriter(System.out);
        int n =fs.nextInt();
        char[] mas = new char[n];
        int[] m1 = new int[n];
        int and = -1;
        int or = -1;
        int xor= -1;
        int[] bits = new int[10];
        int[] xors = new int[10];
        for (int i =0 ; i<10; i++) {
            bits[i] = -1;
            xors[i] = -1;
        }
        for (int i = 0; i<n; i++) {
            mas[i] = fs.nextChar();
            m1[i] = fs.nextInt();
            int val = bits[2];
            for (int j = 0; j<10; j++) {
                if (mas[i] == '&') {
                    if ((m1[i] & (1<<j)) == 0) {
                        bits[j] = 0;
                        xors[j] = 0;
                    }
                } else if (mas[i] == '|') {
                    if (((m1[i] & (1<<j))) == (1<<j)) {
                        bits[j] = 1;
                        xors[j] = 0;
                    }
                } else {
                    if (((m1[i] & (1<<j))) == (1<<j)) {
                        if (xors[j] == -1)
                            xors[j] = 0;
                        xors[j] = (xors[j] + 1) % 2;

                    }
                }
            }
        }
        boolean ok = true;
        for (int i =0 ; i<10; i++) {
            if (bits[i] != -1 || (xors[i] == 1))
                ok = false;
        }
        if (ok)
            pw.println(0);
        else {
            int count = 0;
            boolean or1 = false, and1 = false, xor1 = false;
            int or2 = 0, and2 = 1023, xor2 = 0;
            for (int i = 0; i<10; i++) {
                if (((xors[i] == 0 || xors[i] == -1) &&bits[i] == 0) || (xors[i] == 1 && bits[i] == 1)) {
                    and1 = true;
                    and2-=Math.pow(2, i);
                    if (xors[i] == bits[i] && bits[i] == 1)
                        xors[i] = 0;
                    bits[i] = 0;
                }
                else if (((xors[i] == 0 || xors[i] == -1) &&bits[i] == 1) || (bits[i] == 0 && xors[i] == 1)) {
                    or1 = true;
                    or2 += Math.pow(2, i);
                    if (bits[i] ==0 && xors[i] == 1) {
                        xors[i] = 0;
                    }
                    bits[i] = 1;
                }
                if (xors[i] == 1) {
                    xor1 = true;
                    xor2 += Math.pow(2, i);
                }
            }
            if (or1 == true)
                count++;
            if (and1 == true)
                count++;
            if (xor1 == true)
                count++;
            pw.println(count);
            if (or1 == true) {
                pw.println("| " + or2);
            }
            if (and1 == true)
                pw.println("& " + and2);
            if (xor1 == true)
                pw.println("^ " + xor2);
        }
        pw.close();
    }
    boolean bfs() {
        int qh = 0, qt = 0;
        q[qt++] = s;
        d = new int[n];
        for (int i =0 ;i <n; i++)
            d[i] = -1;
        d[s] = 0;
        while (qh<qt&&d[t] == -1) {
            int v = q[qh++];
            for (int i =0; i<g[v].size(); i++) {
                int id = g[v].get(i), to = e.get(id).b;
                if (d[to] == -1 && e.get(id).flow < e.get(id).cap) {
                    q[qt++] = to;
                    d[to] = d[v]+1;
                }
            }
        }
        return d[t] !=-1;
    }

    long dfs(int v, int flow) {
        if (flow == 0) return 0;
        if (v == t)
            return flow;
        for (; ptr[v]<g[v].size();  ptr[v]++) {
            int id = g[v].get(ptr[v]), to = e.get(id).b;
            if (d[to] != d[v]+1)
                continue;
            long pushed = dfs(to, Math.min(flow, e.get(id).cap-e.get(id).flow));
            if (pushed!=0) {
                e.get(id).flow +=pushed;
                e.get(id^1).flow -=pushed;
                return pushed;
            }
        }
        return 0;
    }
    long dinic() {
        long flow = 0;
        for (;;) {
            if (!bfs()) break;
            ptr = new int[n];
            long pushed = dfs(s, INF);
            while (pushed !=0){
                flow+=pushed;
                pushed = dfs(s, INF);
            }
        }
        return flow;
    }

}
class Edge {
    int a, b, cap, flow;

    Edge(int a1, int b1, int cap1, int flow1) {
    a =a1;
    b =b1;
    cap =cap1;
    flow =flow1;
}
}
class Triple{
    int x;
    int y;
    int z;
    Triple(int a, int b, int c) {
        x = a;
        y = b;
        z = c;
    }
}

class FScanner {
    StringTokenizer st;
    BufferedReader reader;
    FScanner(InputStreamReader isr) throws IOException {
        reader = new BufferedReader(isr);
    }

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

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

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

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

    char nextChar() throws IOException {
        return (char) reader.read();
    }

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

    int[] iarr(int n) throws IOException {
        int[] mas = new int[n];
        for (int i =0 ; i<n; i++)
            mas[i] = nextInt();
        return mas;
    }

    double[] darr(int n) throws IOException {
        double[] mas = new double[n];
        for (int i =0 ; i<n; i++)
            mas[i] = nextDouble();
        return mas;
    }

    char[][] cmas2 (int n, int m) throws IOException {
        char[][] mas = new char[n][m];
        for (int i =0 ; i<n; i++)
            mas[i] = nextLine().toCharArray();
        return mas;
    }

    long[] larr(int n) throws IOException {
        long[] mas = new long[n];
        for (int i =0 ; i<n; i++)
            mas[i] = nextLong();
        return mas;
    }

}