Problem: Petya learned a new programming language CALPAS. A program in this language always takes one non-negative integer and returns one non-negative integer as well.

In the language, there are only three commands: apply a bitwise operation AND, OR or XOR with a given constant to the current integer. A program can contain an arbitrary sequence of these operations with arbitrary constants from 0 to 1023. When the program is run, all operations are applied (in the given order) to the argument and in the end the result integer is returned.

Petya wrote a program in this language, but it turned out to be too long. Write a program in CALPAS that does the same thing as the Petya's program, and consists of no more than 5 lines. Your program should return the same integer as Petya's program for all arguments from 0 to 1023.

Input

The first line contains an integer n (1 ≤ n ≤ 5·105) — the number of lines.

Next n lines contain commands. A command consists of a character that represents the operation ("&", "|" or "^" for AND, OR or XOR respectively), and the constant xi 0 ≤ xi ≤ 1023.

Output

Output an integer k (0 ≤ k ≤ 5) — the length of your program.

Next k lines must contain commands in the same format as in the input.

Examples

Input

3
| 3
^ 2
| 1


Output

2
| 3
^ 2


Input

3
&amp; 1
&amp; 3
&amp; 5


Output

1
&amp; 1


Input

3
^ 1
^ 2
^ 3


Output

0

Note

You can read about bitwise operations in <https://en.wikipedia.org/wiki/Bitwise_operation>.

Second sample:

Let x be an input of the Petya's program. It's output is ((x&1)&3)&5 = x&(1&3&5) = x&1. So these two programs always give the same outputs.

Solution (in PYTHON):

Solution:
#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
        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(andval)))
    write(('| ' + str(orval)))
    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()