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

n = int(raw_input())

# a = 0
# b = 1023

targa = 0
targb = 1023

for i in xrange(n):
    stuff = raw_input().split()
    if stuff[0] == '|':
        targa = targa | int(stuff[1])
        targb = targb | int(stuff[1])
    elif stuff[0] == '^':
        targa = targa ^ int(stuff[1])
        targb = targb ^ int(stuff[1])
    else:
        targa = targa & int(stuff[1])
        targb = targb & int(stuff[1])
        
astr = bin(targa)[2:].zfill(10)
bstr = bin(targb)[2:].zfill(10)

orstr = ""
andstr = ""
xorstr = ""

for i in xrange(10):
    a = astr[i]
    b = bstr[i]
    if a == '0':
        andstr += b
        orstr += '0'
        xorstr += '0'
    elif b == '1':
        andstr += '1'
        orstr += a
        xorstr += '0'
    else:
        andstr += '1'
        orstr += '0'
        xorstr += '1'
        
print 3
print '& ' + str(int(andstr, 2))
print '| ' + str(int(orstr, 2))
print '^ ' + str(int(xorstr, 2))
