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

#NYAN NYAN
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
#░░░░░░░░░░▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄░░░░░░░░░
#░░░░░░░░▄▀░░░░░░░░░░░░▄░░░░░░░▀▄░░░░░░░
#░░░░░░░░█░░▄░░░░▄░░░░░░░░░░░░░░█░░░░░░░
#░░░░░░░░█░░░░░░░░░░░░▄█▄▄░░▄░░░█░▄▄▄░░░
#░▄▄▄▄▄░░█░░░░░░▀░░░░▀█░░▀▄░░░░░█▀▀░██░░
#░██▄▀██▄█░░░▄░░░░░░░██░░░░▀▀▀▀▀░░░░██░░
#░░▀██▄▀██░░░░░░░░▀░██▀░░░░░░░░░░░░░▀██░
#░░░░▀████░▀░░░░▄░░░██░░░▄█░░░░▄░▄█░░██░
#░░░░░░░▀█░░░░▄░░░░░██░░░░▄░░░▄░░▄░░░██░
#░░░░░░░▄█▄░░░░░░░░░░░▀▄░░▀▀▀▀▀▀▀▀░░▄▀░░
#░░░░░░█▀▀█████████▀▀▀▀████████████▀░░░░
#░░░░░░████▀░░███▀░░░░░░▀███░░▀██▀░░░░░░
#░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
from __future__ import print_function
import os
import sys
import fileinput
import codecs
import operator
import functools
import math
inval = None
file = None
Debug = True
import time

def readSequence(elementType=int, inputLine=None, seperator=' ', strip=True):
    global file
    if (inputLine == None):
        inputLine = file.readline()
    if strip:
        inputLine = inputLine.strip()
    return [elementType(x) for x in inputLine.split(seperator)]

def C(n, r):
    r = min(r, (n - r))
    if (r == 0):
        return 1
    if (r < 0):
        return 0
    numer = functools.reduce(operator.mul, range(n, (n - r), (-1)))
    denom = functools.reduce(operator.mul, range(1, (r + 1)))
    return (numer // denom)

def sumdigit(num):
    num = str(num)
    r = 0
    for x in num:
        r = (r + int(x))
        pass
    return r

def digitListToInt(numList):
    return int(''.join(map(str, numList)))

def listByDigit(digitLen):
    return [0 for _ in range(digitLen)]

def F(n, k):
    ans = 0
    for x in range(1, n):
        ans = (ans + (x * C((n - x), (k - 1))))
        pass
    return ans
    pass

def keyWithMaxValue(d1):
    v = list(d1.values())
    return list(d1.keys())[v.index(max(v))]

def checkProperIrreducible(a, b):
    if (a == 1):
        return True
    if (a == b):
        return False
    if (a > b):
        return checkProperIrreducible(b, a)
    else:
        return checkProperIrreducible(a, (b - a))

class MultiArray(object, ):

    def MultiArray(defaultList, listCount):
        this.Lists[0] = defaultList
        for i in range(1, listCount):
            this.Lists[i] = list()
        pass

    def MultiArray(listCount):
        for i in range(listCount):
            this.Lists[i] = list()
        pass

    def MakeRankList(idx):
        input = this.Lists[0]
        output = ([0] * len(input))
        for (i, x) in enumerate(sorted(range(len(input)), key=(lambda y: input[y]))):
            output[x] = i
        this.Lists[idx] = output
        pass
    pass

def solve():
    solve879c()
    pass

def solve879a():
    rs = RobertsSpaceIndustries = readSequence
    n = rs()[0]
    cur = 0
    for x in range(n):
        li = rs()
        s = li[0]
        d = li[1]
        i = 0
        while (cur >= (s + (d * i))):
            i += 1
            pass
        cur = (s + (d * i))
    write(cur)
    pass

def solve879b():
    rs = RobertsSpaceIndustries = readSequence
    li = rs()
    (n, k) = (li[0], li[1])
    li = rs()
    arr = li
    wins = ([0] * (n + 3))
    if (k > 600):
        write(n)
        return
    while True:
        a = arr[0]
        b = arr[1]
        if (a > b):
            arr = (([a] + arr[2:]) + [b])
            wins[a] += 1
            if (wins[a] == k):
                write(a)
                return
            pass
        else:
            arr = (([b] + arr[2:]) + [a])
            wins[b] += 1
            if (wins[b] == k):
                write(b)
                return
            pass
        pass
    pass

def solve879c():
    rs = RobertsSpaceIndustries = readSequence
    n = rs()[0]
    onbits = 1023
    offbits = 0
    for x in range(n):
        li = rs(elementType=str)
        if (li[0] == '&'):
            onbits = (onbits & int(li[1]))
            offbits = (offbits & int(li[1]))
            pass
        elif (li[0] == '|'):
            onbits = (onbits | int(li[1]))
            offbits = (offbits | int(li[1]))
            pass
        else:
            onbits = (onbits ^ int(li[1]))
            offbits = (offbits ^ int(li[1]))
            pass
        pass
    orbits = ([0] * 10)
    andbits = ([1] * 10)
    xorbits = ([0] * 10)
    for x in range(10):
        if (((onbits & pow(2, x)) != 0) and ((offbits & pow(2, x)) != 0)):
            orbits[x] = 1
        if (((onbits & pow(2, x)) == 0) and ((offbits & pow(2, x)) == 0)):
            andbits[x] = 0
        if (((onbits & pow(2, x)) == 0) and ((offbits & pow(2, x)) != 0)):
            xorbits[x] = 1
        if (((onbits & pow(2, x)) != 0) and ((offbits & pow(2, x)) == 0)):
            xorbits[x] = 1
        pass
    orval = 0
    andval = 0
    xorval = 0
    for x in range(len(orbits)):
        orval += (orbits[x] * pow(2, x))
    for x in range(len(andbits)):
        andval += (andbits[x] * pow(2, x))
    for x in range(len(xorbits)):
        xorval += (xorbits[x] * pow(2, x))
    write('3')
    write(('| ' + str(orval)))
    write(('& ' + str(andval)))
    write(('^ ' + str(xorval)))
    pass

def ToSpaceSeperatedString(targetList):
    return ' '.join(map(str, targetList))

def solveTemplate():
    global file
    rl = file.readline
    rs = RobertsSpaceIndustries = readSequence
    li = rs()
    (n, x) = (li[0], li[1])
    pass
inval = None

def write(str1):
    print(str1)
ti = time.time()
file = fileinput.input(inval)
solve()
