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 JAVA):

Solution:
import java.io.* ;
import java.util.* ;
import java.math.* ;
public class CodeForces{
	public static void main(String[] args) throws IOException{
		Solver Machine = new Solver() ;
		Machine.Solve() ;	
		Machine.Finish();
	}	
}
class Mod{
	static long mod=1000000007 ;
	static long d(long a,long b){ return (a*MI(b))%mod ; }
	static long m(long a , long b){ return (a*b)%mod ; }
	static private long MI(long a ){ return pow(a,mod-2) ; }
	static long pow(long a,long b){
		if(b<0) return pow(MI(a),-b) ;
		long val=a ; long ans=1 ;
		while(b!=0){
			if((b&1)==1) ans = (ans*val)%mod ; 
			val = (val*val)%mod ; 
			b>>=1 ;
		}
		return ans ;
	}	
}
class pair implements Comparable<pair>{
	long x ; long y ; 
	pair(long x,long y){ this.x=x ; this.y=y ;}
	public int compareTo(pair p){
		return (this.x<p.x ? -1 : (this.x>p.x ? 1 : (this.y<p.y ? -1 : (this.y>p.y ? 1 : 0)))) ;
	}
}
class Solver{	
	FasterScanner ip = new FasterScanner(System.in) ;	  
	PrintWriter op = new PrintWriter(System.out) ;
	void Solve() throws IOException{
		int opr[] = new int[10] ;
		for(int i=0 ; i<10 ; i++) opr[i] = 2 ;
		int n = ip.i() ;
		for(int j=0 ; j<n ; j++){
			char c = ip.S().charAt(0) ;
			int vl = ip.i() ;
			for(int i=0 ; i<10 ; i++){
				int bit = vl&1 ;
				switch(c){
					case '&' : {
						if(bit==0) opr[i]=0 ;
					}break ;
					case '|' : {
						if(bit==1) opr[i]=1 ;
					}break ;
					case '^' : {
						if(bit==1){
							if(opr[i]==0 || opr[i]==1) opr[i]=1-opr[i] ;
							else opr[i]=-opr[i] ;
						}
					}
				}
				vl>>=1 ;
			}
		}
		int xor[] = new int[10] ;
		int and[] = new int[10] ;
		Arrays.fill(and,1) ;
		int or[] = new int[10] ;
		for(int i=0 ; i<10 ; i++){ 
			if(opr[i]==-2) xor[i]=1 ;
			if(opr[i]==0) and[i]=0 ;
			if(opr[i]==1) or[i]=1 ;
		}
		/*pArr("opr",opr,'i',0) ;
		pArr("xor",xor,'i',0) ;
		pArr("and",and,'i',0) ;
		pArr("or",or,'i',0) ;*/
		pln(3) ;
		pln("^ "+num(xor)) ;
		pln("& "+num(and)) ;
		pln("| "+num(or)) ;
	}
	int num(int arr[]){
		int res=0 ;
		for(int i=9 ; i>=0 ; i--){
			int bit = arr[i] ;
			res = (res<<1)|bit ;
		}
		return res ;
	}
	void p(Object o){
		op.print(o) ;
	}
	void pln(Object o){
		op.println(o) ;
	}
	void pArr(String name,Object arr,char type,int st){
		p(name+": [") ;
		if(type=='i'){ 
			int arr1[] = (int[]) arr ;
			for(int i=st ; i<arr1.length ; i++) p(arr1[i]+(i+1==arr1.length ? "" : ",")) ;		 
		}else if(type=='l'){ 
			long arr1[] = (long[]) arr ;
			for(int i=st ; i<arr1.length ; i++) p(arr1[i]+(i+1==arr1.length ? "" : ",")) ;
		}else if(type=='b'){
			boolean arr1[] = (boolean[]) arr ;
			for(int i=0 ; i<arr1.length ; i++) p((arr1[i] ? 1 : 0)+(i+1==arr1.length ? "" : ",")) ;
		}
		pln("]") ;
	}	
	void Finish(){
		op.flush();
		op.close();
	}	
}
@SuppressWarnings("serial")
class mylist extends ArrayList<Integer>{
}
@SuppressWarnings("serial")
class myset extends TreeSet<Long>{
}
@SuppressWarnings("serial")
class mystack extends Stack<Integer>{
}
@SuppressWarnings("serial")
class mymap extends TreeMap<Long,Integer>{
}
class FasterScanner { 
	private InputStream mIs;
	private byte[] buf = new byte[1024];
	private int curChar,numChars;
	public FasterScanner() { this(System.in); } 
	public FasterScanner(InputStream is) { mIs = is;} 
	public int read() {
		if (numChars == -1) throw new InputMismatchException();    
		if (curChar >= numChars) {
			curChar = 0;
			try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}
			if (numChars <= 0) return -1;            
		}
		return buf[curChar++];
	} 
	public String nextLine(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	} 
	public String S(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		}while (!isSpaceChar(c));
		return res.toString();
	} 
	public long l(){
		int c = read();
		while (isSpaceChar(c)) c = read();        
		int sgn = 1;
		if (c == '-') { sgn = -1 ; c = read() ; }
		long res = 0;
		do{
			if (c < '0' || c > '9') throw new InputMismatchException();
			res *= 10 ; res += c - '0' ; c = read();
		}while(!isSpaceChar(c));
		return res * sgn;
	} 
	public int i(){
		int c = read() ;
		while (isSpaceChar(c)) c = read();        
		int sgn = 1;
		if (c == '-') { sgn = -1 ; c = read() ; }
		int res = 0;
		do{
			if (c < '0' || c > '9') throw new InputMismatchException();
		res *= 10 ; res += c - '0' ; c = read() ;
		}while(!isSpaceChar(c));
		return res * sgn;
	} 
	public int[] ia(int n){
		int a[] = new int[n] ;
		for(int i=0 ; i<n ; i++) a[i] = i() ;
		return a ;
	}
	public long[] la(int n){
		long a[] = new long[n] ;
		for(int i=0 ; i<n ; i++) a[i] = l() ;
		return a ;
	}
	public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
	public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
}