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

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class main
{
	private static InputStream stream;
	private static byte[] buf = new byte[1024];
	private static int curChar;
	private static int numChars;
	private static SpaceCharFilter filter;
	private static PrintWriter pw;
	private static long mod = 1000000000 + 7;

	private static void soln()
	{
		/*int n = nextInt();
		long k = nextLong();
		int[] arr = new int[n];
		int max = Integer.MIN_VALUE;
		for(int i=0;i<n;i++) {
			arr[i] = nextInt();
			max = Math.max(arr[i], max);
		}
		if(k>=n-1)
			pw.println(max);
		else {
			int max1 = Math.max(arr[0],arr[1]);
			int k1 = 1;
			for(int i=2;i<n && k1<=k; i++) {
				if(max1<arr[i]) {
					k1++;
					max1 = arr[i];
				}else
					k1 = 1;
				if(k1==k)
					break;
			}
			pw.println(max1);
		}*/
		int n = nextInt();
		ArrayList<Integer>[] l = new ArrayList[4];
		for(int i=0;i<4;i++)
			l[i] = new ArrayList<>();
		String[][] arr = new String[n][2];
		for(int i=0;i<n;i++)
			arr[i] = nextLine().split(" ");
		for(int i=0;i<10;i++) {
			int b1 = 0;
			int b2 = 1;
			for(int j=0;j<n;j++) {
				int bit = Integer.parseInt(arr[j][1]);
				bit = ((bit&(1<<i))>>i);
				if(arr[j][0].charAt(0)=='|') {
					b1 |= bit;
					b2 |= bit;
				}
				else if(arr[j][0].charAt(0)=='&') {
					b1 &= bit;
					b2 &= bit;
				}
				else {
					b1 ^= bit;
					b2 ^= bit;
				}
			}
			if(b1 == 0 && b2 == 1) {
				l[0].add(i);
			}else if(b1 == 1 && b2 == 1) {
				l[1].add(i);
			}else if(b1 == 0 && b2 == 0) {
				l[2].add(i);
			}else {
				l[3].add(i);
			}
		}
		pw.println(3);
		int num = 0;
		for(int x: l[1]) {
			num += (1<<x);
		}
		pw.println("| "+num);
		num = 1023;
		for(int x: l[2]) {
			num ^= (1<<x);
		}
		pw.println("& "+num);
		num = 0;
		for(int x: l[3]) {
			num += (1<<x);
		}
		pw.println("^ "+num);
	}
	
	private static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	
	private static class Pair implements Comparable<Pair>{
		long val;
		int br;
		public Pair(long a,int b) {
			val=a;
			br=b;
		}
		@Override
		public int compareTo(Pair arg0)
		{
			return (int) (this.val-arg0.val);
		}
	}
	private static long pow(long a, long b, long c)
	{
		if (b == 0)
			return 1;
		long p = pow(a, b / 2, c);
		p = (p * p) % c;
		return (b % 2 == 0) ? p : (a * p) % c;
	}

	private static long gcd(long n, long l)
	{
		if (l == 0)
			return n;
		return gcd(l, n % l);
	}

	public static void main(String[] args) throws Exception
	{
//		new Thread(null, new Runnable()
//		{
//			@Override
//			public void run()
//			{
//				/*
//				 * try { InputReader(new
//				 * FileInputStream("C:\\Users\\hardik\\Desktop\\B-large-practice.in")); } catch
//				 *) (FileNotFoundException e) { // TODO Auto-generated catch block
//				 * e.printStackTrace(); }
//				 */
//				InputReader(System.in);
//				pw = new PrintWriter(System.out);
//				/*
//				 * try { pw=new PrintWriter(new
//				 * FileOutputStream("C:\\Users\\hardik\\Desktop\\out.txt")); } catch
//				 * (FileNotFoundException e) { // TODO Auto-generated catch block
//				 * e.printStackTrace(); }
//				 */
//				soln();
//				pw.close();
//			}
//		}, "1", 1 << 26).start();

		/*
		 * try { InputReader(new
		 * FileInputStream("C:\\Users\\hardik\\Desktop\\B-large-practice.in")); } catch
		 * (FileNotFoundException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 */
		 InputReader(System.in);
		 pw = new PrintWriter(System.out);
		/*
		 * try { pw=new PrintWriter(new
		 * FileOutputStream("C:\\Users\\hardik\\Desktop\\out.txt")); } catch
		 * (FileNotFoundException e) { // TODO Auto-generated catch block
		 * e.printStackTrace(); }
		 */
		soln();
		pw.close();
	}

	public static void InputReader(InputStream stream1)
	{
		stream = stream1;
	}

	private static boolean isWhitespace(int c)
	{
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private static boolean isEndOfLine(int c)
	{
		return c == '\n' || c == '\r' || c == -1;
	}

	private static int read()
	{
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars)
		{
			curChar = 0;
			try
			{
				numChars = stream.read(buf);
			} catch (IOException e)
			{
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private static int nextInt()
	{
		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;
	}

	private static long nextLong()
	{
		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;
	}

	private static String nextToken()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do
		{
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private static 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();
	}

	private static int[] nextIntArray(int n)
	{
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
		{
			arr[i] = nextInt();
		}
		return arr;
	}

	private static long[] nextLongArray(int n)
	{
		long[] arr = new long[n];
		for (int i = 0; i < n; i++)
		{
			arr[i] = nextLong();
		}
		return arr;
	}

	private static void pArray(int[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static void pArray(long[] arr)
	{
		for (int i = 0; i < arr.length; i++)
		{
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private static boolean isSpaceChar(int c)
	{
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private static char nextChar()
	{
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1 = (char) c;
		while (!isSpaceChar(c))
			c = read();
		return c1;
	}

	private interface SpaceCharFilter
	{
		public boolean isSpaceChar(int ch);
	}
}