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())
bits = [[0 for x in range(10)] for x in range(2)]
bits[1] = [1 for x in range(10)]
for i in range(n):
  a,b = raw_input().split()
  b = int(b)
  temp = [0 for x in range(10)]
  cur = 0
  while b:
    temp[cur] = b%2
    b /= 2
    cur += 1
  if a=='|':
    for j in range(10):
      if temp[j]:
        bits[0][j] = 1
        bits[1][j] = 1
  elif a=='^':
    for j in range(10):
      bits[0][j] ^= temp[j]
      bits[1][j] ^= temp[j]
  else:
    for j in range(10):
      bits[0][j] &= temp[j]
      bits[1][j] &= temp[j]
ans = [0,1023,0]
val = [0,0,0]
pr = '|&^'
for i in range(10):
  if bits[0][i] and bits[1][i]:
    ans[0] |= (1<<i)
    val[0] = 1
  elif not bits[1][i] and not bits[0][i]:
    ans[1] ^= (1<<i)
    val[1] = 1
  elif bits[0][i] and not bits[1][i]:
    ans[2] |= (1<<i)
    val[2] = 1
print sum(val)
for i in range(3):
  if val[i]:
    print pr[i],ans[i]