#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int ctoi(char ch)
{
  return ch - '0';
}

int main()
{
  int n;
  int init, fin;
  int answer;
  scanf("%d\n", &n);
  char *initial = malloc(sizeof(char) * (n + 1));
  char *final = malloc(sizeof(char) * (n + 1));
  scanf("%1000s\n", initial);
  scanf("%1000s", final);
  for(int i = 0; i < n; i++)
  {
    init = ctoi(initial[i]);
    fin = ctoi(final[i]);
    answer += abs(init - fin) > 5 ? 10 - abs(init - fin) : abs(init - fin);
  }
  printf("%d\n", answer);
  return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,n,m,a,b,c,s=0;
    scanf("%d\n",&n);
    char s1[1000],s2[1000];
    gets(s1);
    gets(s2);
    for(i=0;i<n;i++)
    {
        c=s1[i]-s2[i];
        s=s+c;
    }
    printf("%d",s);
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    char a[1000];
    char b[1000];
    int n,i,k;
    int l=0;
    scanf("%d",&n);

        scanf("%s",a);
        scanf("%s",b);
        for(i=0;i<n;i++){
                k=abs(a[i]-b[i]);
                if(k>5)
                    k=10-k;
                    l=l+k;

                    }
                    printf("%d",l);

}


#include<stdio.h>
#include<math.h>
#define min(x,y) x>=y?y:x
int main()
{

    int n,count=0,i,c,d;
     char a[1001],b[1001],p[1001];
    scanf("%d",&n);
    scanf("%s",a);
    scanf("%s",b);
    for(i=0;i<n;i++)
    {
      c=abs((int)a[i]-(int)b[i]);
      d=10-c;
      p[i]=min(c,d);
      count=count+p[i];
    }
        printf("%d",count);
   return 0;
}


#include<stdio.h>
#include<math.h>
#define min(x,y) x>=y?y:x
int main()
{
 int n,i,x,y,sum=0;
 scanf("%d",&n);
 int a[n],b[n],p[n];
 for(i=0;i<n;i++)
 scanf("%d",&a[i]);
 for(i=0;i<n;i++)
 scanf("%d",&b[i]);
 for(i=0;i<n;i++){
    x=abs(a[i]-b[i]);
    y=10-abs(a[i]-b[i]);
    p[i]=min(x,y);}
 for(i=0;i<n;i++)
    sum=sum+p[i];
 printf("%d",sum);
 return 0;
}


#include<stdio.h>
#include<math.h>
#define min(x,y) x>=y?y:x
int main()
{

    int n,count=0,i,c,d;
     char a[1001],b[1001],q[1001];
    scanf("%d",&n);
    scanf("%s",a);
    scanf("%s",b);
    for(i=0;i<n;i++)
    {
      c=abs((int)a[i]-(int)b[i]);
      d=10-c;
      q[i]=min(c,d);
      count=count+q[i];
    }
        printf("%d",count);
   return 0;
}


#include<stdio.h>
#include<math.h>
#define min(x,y) x>=y?y:x
int main()
{
int n,i,x,y,sum=0;
scanf("%d\n",&n);
char a[n+1],b[n+1],p[n+1];
scanf("%s",a);
scanf("%s",b);
for(i=0;i<n;i++){
    x=abs(a[i]-b[i]);
    y=10-abs(a[i]-b[i]);
    p[i]=min(x,y);
}
for(i=0;i<n;i++)
    sum=sum+p[i];
printf("%d",sum);
return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
	int n,i,back,front,c=0;
	char k[100],x[100];
	scanf("%d",&n);
	scanf("%s",&k);
	scanf("%s",&x);
	for(i=0;i<n;i++){
		front = abs(k[i] - x[i]);
		back = 10 - front;
		if(front < back){
			c += front;
		}else{
			c += back;
		}
	}
	printf("%d",c);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
	int n,i,back,front,c=0;
	char k[100],x[100];
	scanf("%d",&n);
	scanf("%s",&k);
	scanf("%s",&x);
	for(i=0;i<n;i++){
		front = abs(k[i] - x[i]);
		back = 10 - front;
		if(front < back){
			c += front;
		}else{
			c += back;
		}
	}
	printf("%d",c);
	return 0;


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]){
	int n,i,back,front,c=0;
	char k[1000],x[1000];
	scanf("%d",&n);
	scanf("%s",&k);
	scanf("%s",&x);
	for(i=0;i<n;i++){
		front = abs(k[i] - x[i]);
		back = 10 - front;
		if(front < back){
			c += front;
		}else{
			c += back;
		}
	}
	printf("%d",c);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,n,count=0;
    scanf("%d",&n);
    int ara[100],ara1[100];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);

    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara1[i]);
    }
    for(i=0;i<n;i++)
    {
        if(ara[i]==ara1[i])
        {
            count=count+0;
        }
        else if(ara[i]!=ara1[i] && ara[i]-ara1[i]>0 && ara[i]-ara1[i]<=5)
            {
                count=count+ara[i]-ara1[i];
            }
            else if(ara[i]!=ara1[i] && ara[i]-ara1[i]<0  && ara[i]-ara1[i]>=-5)
            {
                count=count+ara1[i]-ara[i];
            }
            else if(ara[i]!=ara1[i]&& ara[i]-ara1[i]>5)
            {
                count=count+10+ara1[i]-ara[i];
            }
            else if(ara[i]!=ara1[i]&& ara[i]-ara1[i]<-5)
            {
                count=count+10+ara[i]-ara1[i];
            }
    }
    printf("%d",count);

}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,count=0;
    scanf("%d",&n);
    int ara[1000],ara1[1000];
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
    }
     for(i=0;i<n;i++)
    {
        scanf("%d",&ara1[i]);
    }
    for(i=0;i<n;i++)
    {
        int a=ara[i]-ara1[i];
        if(a==0)
        {
            count=count+0;
        }
      else if(a<6 && a>=1)
      {
          count=count+a;
      }
      else if(a>=6)
      {
          count=count+10-a;
      }
      else if(a>-6 && a<=-1)
      {
          count=count+(-1*a);
      }
      else if( a<=-6)
      {
          count=count+a+10;
      }
    }
    printf("%d",count);
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,i,j,a,count=0,a1,a2;
    scanf("%d",&n);
    getchar();
       char ch[10000],ch1[100000];
   gets(ch);
   gets(ch1);
    for(i=0;i<n;i++)
    {
        a1=ch[i]-'0';

        a2=ch1[i]-'0';
        a=a1-a2;
        if(a<0)
        {
            a=-1*a;
        }
        if(a==0)
        {
            count=count+0;
        }
        else if(a>0 && a<6)
        {
            count=count+a;
        }
        else if(a>=6)
        {
            count=count+10-a;
        }
    }
    printf("%d",count);
}


#include <stdio.h>
int main()
{
    int i,n,ridit[101],sum=0;
    char s1[101],s2[101],ridiot[101];
    scanf("%d %s %s",&n,s1,s2);
    for(i=0; i<n; i++)
    {
        ridit[i]=s1[i]-48;
        ridiot[i]=s2[i]-48;
    }
    for(int i=0; i<n; i++)
    {
        if(ridit[i]>ridiot[i])
        {
            if(ridit[i]-ridiot[i]<=5)
                sum+=ridit[i]-ridiot[i];
            else if(ridit[i]-ridiot[i]>5)
                sum+=ridiot[i]+10-ridit[i];
        }
        else if(ridit[i]<ridiot[i])
        {
            if(ridiot[i]-ridit[i]<=5)
                sum+=ridiot[i]-ridit[i];
            else if(ridiot[i]-ridit[i]>5)
                sum+=ridit[i]+10-ridiot[i];
        }
    }
    printf("%d",sum);
}


#include <stdio.h>
int main()
{
    int i,n,ridit[101],sum=0;
    scanf("%d",&n);
    char s1[n],s2[n],ridiot[n];
    scanf("%d %s %s",&n,s1,s2);
    for(i=0; i<n; i++)
    {
        ridit[i]=s1[i]-48;
        ridiot[i]=s2[i]-48;
    }
    for(int i=0; i<n; i++)
    {
        if(ridit[i]>ridiot[i])
        {
            if(ridit[i]-ridiot[i]<=5)
                sum+=ridit[i]-ridiot[i];
            else if(ridit[i]-ridiot[i]>5)
                sum+=ridiot[i]+10-ridit[i];
        }
        else if(ridit[i]<ridiot[i])
        {
            if(ridiot[i]-ridit[i]<=5)
                sum+=ridiot[i]-ridit[i];
            else if(ridiot[i]-ridit[i]>5)
                sum+=ridit[i]+10-ridiot[i];
        }
    }
    printf("%d",sum);
}


#include <stdio.h>
int main()
{
    int i,sum=0,n;
    scanf("%d",&n);
    int p[n],q[n];
    char ridit[n],ridiot[n];
    scanf("%s %s",ridit,ridiot);
    for(i=0; i<n; i++)
    {
        p[i]=ridit[i]-48;
        q[i]=ridiot[i]-48;
    }
    for(i=0; i<n; i++)
    {
        if(p[i]>q[i])
        {
            if(p[i]-q[i]<=5)
                sum+=p[i]-q[i];
            else if(p[i]-q[i]>5)
                sum+=q[i]+10-p[i];
        }
        else if(p[i]<q[i])
        {
            if(q[i]-p[i]<=5)
                sum+=q[i]-p[i];
            else if(q[i]-p[i]>5)
                sum+=p[i]+10-q[i];
        }
    }
    printf("%d",sum);
}


#include<stdio.h>
#include<stdio.h>
int main()
{
    int a,i,len,llen,c,d,n,j,s=0;
    char str[100],str1[100];
    scanf("%d",&n);
    getchar();
    gets(str);
    gets(str1);
    len=strlen(str);
    llen=strlen(str1);
    for(i=0,j=0;i<len,j<llen;i++,j++)
    {
        c=str[i]-str1[j];
        if(c<0)
        c=str1[j]-str[i];
        d=c;
        if(d>=5)
        {
            d=10-c;
        }
        s=s+d;

    }
    printf("%d\n",s);
    return 0;
}


#include<stdio.h>
#include<stdio.h>
int main()
{
    int a,i,len,llen,c,d,n,j,s=0;
    char str[2000],str1[2000];
    scanf("%d",&n);
    getchar();
    gets(str);
    gets(str1);
    len=strlen(str);
    for(i=0;i<len;i++)
    {
        c=abs(str[i]-str1[i]);
        if(c>=5)
        {
            c=10-c;
        }
        s=s+c;

    }
    printf("%d\n",s);
    return 0;
}


#include<stdio.h>
#include<stdio.h>
int main()
{
    int a,i,len,llen,c,k=0,n,j,ara[100],s=0;
    char str[100],str1[100];
    scanf("%d",&n);
    getchar();
    gets(str);
    gets(str1);
    len=strlen(str);
    llen=strlen(str1);
    for(i=0,j=0;i<len,j<llen;i++,j++)
    {
        c=str[i]-str1[j];
        if(c<0)
        c=str1[j]-str[i];
        ara[k]=c;
        k++;

    }
    for(i=0;i<len;i++)
    {
        if(ara[i]>=5)
            ara[i]=10-ara[i];
        s=s+ara[i];
    }
    printf("%d\n",s);
    return 0;
}


#include<stdio.h>
#include<stdio.h>
int main()
{
    int a,i,len,llen,c,d,n,j,s=0;
    char str[1000],str1[1000];
    scanf("%d",&n);
    getchar();
    gets(str);
    gets(str1);
    len=strlen(str);
    for(i=0;i<len;i++)
    {
        c=abs(str[i]-str1[i]);
        if(c>=5)
        {
            c=10-c;
        }
        s=s+c;

    }
    printf("%d\n",s);
    return 0;
}


#include<stdio.h>
int main()
{
    long long int i,n,x,y,sum=0;
    char a[1000],b[1000];
    scanf("%lld%s%s",&n,a,b);
    for(i=0;i<n;i++)
    {
        if(a[i]>b[i])
        {
            x=(10+b[i]-a[i]);
            y=a[i]-b[i];
            if(x<y)
                sum+=x;
            else sum+=y;

        }
        else
        {
            x=(10+a[i]-b[i]);
            y=b[i]-a[i];
            if(x<y)
                sum+=x;
            else sum+=y;

        }
    }
    printf("%lld\n",sum);

}


#include<stdio.h>
#include<math.h>
int main()
{

    int n,i,j,s=0,p=0,m=0,k=0;
    scanf("%d",&n);
    char b [1009];
    char c[1009];
    scanf("%s",&b);
    scanf("%s",&c);
    for(i=0;i<n;i++)
    {
           if(b[i]>c[i])
            s=c[i]+10-b[i];
          else if(b[i]<c[i])
            s=b[i]+10-c[i];

      if(b[i]>c[i])
      p=b[i]-c[i];
       else if(b[i]<c[i])
         p=c[i]-b[i];
     if(abs(s)<abs(p))
    {
        m+=abs(s);
    }
    else if(abs(s)>abs(p))
    {
        m+=abs(p);
    }
    }
    printf("%d\n",m);

}


#include<stdio.h>
#include<math.h>
int main()
{

    int n,i,j,s=0,p=0,m=0,k=0;
    scanf("%d",&n);
    char b [1009];
    char c[1009];
    scanf("%s",&b);
    scanf("%s",&c);
    for(i=0;i<n;i++)
    {
           if(b[i]>c[i])
            s=c[i]+10-b[i];
          else if(b[i]<c[i])
            s=b[i]+10-c[i];

      p=b[i]-c[i];
     if(abs(s)<abs(p))
    {
        m+=abs(s);
    }
    else if(abs(s)>abs(p))
    {
        m+=abs(p);
    }
    }
    printf("%d\n",m);

}


#include<stdio.h>
int main()
{
    int n,a,b,c,d=0,sum=0;
    scanf("%d",&n);
    getchar();
    char ar[n+1],ar1[n+1];
    int ar2[n];
    gets(ar);
    gets(ar1);
    for(int i=0;i<n;i++)
    {
        a=ar[i];
        b=ar1[i];
        if(a>b)c=a-b;
        else c=b-a;
        while(a!=b)
        {

            d++;
            if(a>b)
            {
                if(((a++)-9)==b)goto there;
            }
            else
            {
                if(((a--)+9)==b)goto there;
            }
        }
        there:
        if(c>=d)ar2[i]=d;
        else ar2[i]=c;
        d=0;
    }

    for(int i=0;i<n;i++)
    {
        sum=sum+ar2[i];

    }
    printf("%d\n",sum);
}


#include<stdio.h>
int main()
{
    int n,a,b,c,d=0,sum=0;
    scanf("%d",&n);
    getchar();
    char ar[n+1],ar1[n+1];
    int ar2[n];
    gets(ar);
    gets(ar1);
    for(int i=0;i<5;i++)
    {
        a=ar[i];
        b=ar1[i];
        if(a>b)c=a-b;
        else c=b-a;
        while(a!=b)
        {

            d++;
            if(a>b)
            {
                if(((a++)-9)==b)goto there;
            }
            else
            {
                if(((a--)+9)==b)goto there;
            }
        }
        there:
        if(c>=d)ar2[i]=d;
        else ar2[i]=c;
        d=0;
    }

    for(int i=0;i<n;i++)
    {
        sum=sum+ar2[i];

    }
    printf("%d\n",sum);
}


#include<stdio.h>
int main()
{
    int n,a,b,c,d=0,sum=0;
    scanf("%d",&n);
    getchar();
    char ar[n+1],ar1[n+1];
    int ar2[n];
    gets(ar);
    gets(ar1);
    for(int i=0;i<5;i++)
    {
        a=ar[i];
        b=ar1[i];
        if(a>b)c=a-b;
        else c=b-a;
        while(a!=b)
        {

            d++;
            if(a>b)
            {
                if(((a++)-9)==b)goto there;
            }
            else
            {
                if(((a--)+9)==b)goto there;
            }
        }
        there:
        if(c>=d)ar2[i]=d;
        else ar2[i]=c;
        d=0;
    }

    for(int i=0;i<n;i++)
    {
        sum=sum+ar2[i];
        printf("%d\n",ar2[i]);
    }
    printf("%d\n",sum);
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{

	int sum=0,n,a,b;
	scanf("%d %d %d",&n,&a,&b);

	int x=a,y=b;
	for(int j=0;j<n;j++)
	{int r1=a%10,min;
		int r2=b%10;
		/*int min[3],least;
		  min[0]=abs(r1-r2);
		  min[1]=abs(9-r1)+abs(r2-0)+1;
		  min[2]=abs(9-r2)+abs(r1-0)+1;
		  least=min[0];
		  for(int i=1;i<3;i++)
		  {if(least>min[i])
		  {least=min[i];}
		  }
		  sum=sum+least;
		 */
		min=abs(r1-r2);
		if(min<=5)
		{sum=sum+min;}
		else
		{
			if(r1>r2)
			{min=(9-r1)+(r2-0)+1;}
			else {min=(9-r2)+(r1-0)+1;}
			sum=sum+min;
		}

		a=a/10;
		b=b/10;
	}

	//int arr[1000];
	printf("%d\n",sum);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{

	int sum=0,n,a,b;
	scanf("%d %d %d",&n,&a,&b);

	int x=a,y=b;
	for(int j=0;j<n;j++)
	{int r1=a%10;
		int r2=b%10;
		int min[3],least;
		min[0]=abs(r1-r2);
		min[1]=abs(9-r1)+abs(r2-0)+1;
		min[2]=abs(9-r2)+abs(r1-0)+1;
		least=min[0];
		for(int i=1;i<3;i++)
		{if(least>min[i])
			{least=min[i];}
		}
		sum=sum+least;
		a=a/10;
		b=b/10;
	}

	int arr[1000];
	printf("%d\n",sum);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{

	long int sum=0,n,a,b;
	scanf("%ld %ld %ld",&n,&a,&b);

	long int x=a,y=b;
	for(long int j=0;j<n;j++)
	{long int r1=a%10,min;
		long int r2=b%10;
		/*int min[3],least;
		  min[0]=abs(r1-r2);
		  min[1]=abs(9-r1)+abs(r2-0)+1;
		  min[2]=abs(9-r2)+abs(r1-0)+1;
		  least=min[0];
		  for(int i=1;i<3;i++)
		  {if(least>min[i])
		  {least=min[i];}
		  }
		  sum=sum+least;
		 */
		min=abs(r1-r2);
		if(min<=5)
		{sum=sum+min;}
		else
		{
			if(r1>r2)
			{min=(9-r1)+(r2-0)+1;}
			else if(r2>r1)
			{min=(9-r2)+(r1-0)+1;}
			sum=sum+min;
		}

		a=a/10;
		b=b/10;
	}

	//int arr[1000];
	printf("%ld\n",sum);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{

	int sum=0,n;
	char a[1005],b[1005];
	scanf("%d %s %s",&n,a,b);

	//long int x=a,y=b;

	for(long int j=0;j<n;j++)
	{/*long int r1=a%10,min;
	   long int r2=b%10;
	   int min[3],least;
	   min[0]=abs(r1-r2);
	   min[1]=abs(9-r1)+abs(r2-0)+1;
	   min[2]=abs(9-r2)+abs(r1-0)+1;
	   least=min[0];
	   for(int i=1;i<3;i++)
	   {if(least>min[i])
	   {least=min[i];}
	   }
	   sum=sum+least;
	  */
		int min=abs(a[j]-b[j]);
		if(min<=5)
		{sum=sum+min;}
		else
		{
			if(a[j]>b[j])
			{min=(9-a[j])+(b[j]-0)+1;}
			else if(b[j]>a[j])
			{min=(9-b[j])+(a[j]-0)+1;}
			sum=sum+min;
		}

		//a=a/10;
		//b=b/10;
	}

	//int arr[1000];
	printf("%d\n",sum);
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int n,i,c=0,x;
    char a[1002],b[1002];
    scanf("%d%s%s",&n,a,b);
    for(i=0;i<n;i++)
    {
        x=0;
        x=abs(a[i]-b[i]);
        if(x==6)
            x=4;
        if(x==7)
            x=3;
        c=c+x;
    }
    printf("%d\n",c);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int n,i,c=0,x;
    char a[1002],b[1002];
    scanf("%d%s%s",&n,a,b);
    for(i=0;i<n;i++)
    {
        x=0;
        x=abs(a[i]-b[i]);
        if(x>=6)
            x=10-x;
        c=c+x;
    }
    printf("%d\n",c);
    return 0;
}


#include <iostream>
#include <cmath>
using namespace std;
int n,OR[10],AND[10],XOR[10],an,o,xo;
struct node
{
    char op;
    int x;
};
node N[500001];
int check(int bit,int in,int val)
{
    if(N[in].op=='|')return (1<<bit)|N[in].x;
    if(N[in].op=='^')return (1<<bit)^N[in].x;
    else return (1<<bit)&N[in].x;
}
int main()
{
    cin>>n;
    for(int i=0;i<10;i++)AND[i]=1,OR[i]=0,XOR[i]=0;
    for(int i=0;i<n;i++)
    {
        cin>>N[i].op>>N[i].x;
    }
    for(int i=0;i<10;i++)
    {
        int a=0,b=1;
        for(int j=0;j<n;j++)
        {
            a = check(i,j,a);
            b = check(i,j,b);
        }
        if(a==0&&b==0)AND[i]=0;
        if(a==0&&b==1)AND[i]=1;
        if(a==1&&b==1)OR[i]=1;
        if(a==1&&b==0)XOR[i]=1;
    }
    for(int i=0;i<10;i++)
    {
        an+=pow(2,AND[i]);
        o+=pow(2,OR[i]);
        xo+=pow(2,XOR[i]);
    }
    cout<<3<<endl;
    cout<<"| "<<o<<"\n"<<"& "<<an<<"\n"<<"^ "<<xo;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
  #include "debug.h"
#else
  #define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int OR = -1;
  int AND = -1;
  int XOR = -1;
  for (int i = 0; i < n; i++) {
    char c;
    int x;
    cin >> c >> x;
    if (c == '|') {
      OR = OR == -1 ? x : OR | x;
    }
    if (c == '&') {
      AND = AND == -1 ? x : AND & x;
    }
    if (c == '^') {
      XOR = XOR == -1 ? x : XOR ^ x;
    }
  }
  vector<pair<char, int>> op;
  if (OR != -1) {
    op.emplace_back('|', OR);
  }
  if (AND != -1) {
    op.emplace_back('&', AND);
  }
  if (XOR != -1) {
    op.emplace_back('^', XOR);
  }
  cout << (int) op.size() << '\n';
  for (auto p : op) {
    cout << p.first << ' ' << p.second << '\n';
  }
}


#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
  #include "debug.h"
#else
  #define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long OR = -1;
  long long AND = -1;
  long long XOR = -1;
  for (int i = 0; i < n; i++) {
    char c;
    long long x;
    cin >> c >> x;
    if (c == '|') {
      OR = OR == -1 ? x : OR | x;
    }
    if (c == '&') {
      AND = AND == -1 ? x : AND & x;
    }
    if (c == '^') {
      XOR = XOR == -1 ? x : XOR ^ x;
    }
  }
  vector<pair<char, long long>> op;
  if (OR != -1) {
    op.emplace_back('|', OR);
  }
  if (AND != -1) {
    op.emplace_back('&', AND);
  }
  if (XOR != -1) {
    op.emplace_back('^', XOR);
  }
  cout << (int) op.size() << '\n';
  for (auto p : op) {
    cout << p.first << ' ' << p.second << '\n';
  }
}


/**
 *    author:  shafwanur010
 *    created: 9/22/2020 4:19:38 PM (Bangladesh Standard Time)
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
  #include "debug.h"
#else
  #define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> bit(15, -1);
  while (n--) {
    char c;
    int x;
    cin >> c >> x;
    if (c == '|') {
      for (int i = 0; i < 10; i++) {
        bool on = (x >> i) & 1;
        if (on) {
          bit[i] = 1;
        }
      }
    }
    if (c == '&') {
      for (int i = 0; i < 10; i++) {
        bool on = (x >> i) & 1;
        if (!on) {
          bit[i] = 0;
        }
      }
    }
    if (c == '^') {
      for (int i = 0; i < 10; i++) {
        bool on = (x >> i) & 1;
        if (on) {
          if (bit[i] == 0) {
            bit[i] = 1;
          }
          else if (bit[i] == 1) {
            bit[i] = 0;
          }
          else if (bit[i] == -1) {
            bit[i] = 2;
          }
          else if (bit[i] == 2) {
            bit[i] = -1;
          }
        }
      }
    }
  }
  int OR = 0;
  int AND = 0;
  int XOR = 0;
  for (int i = 0; i < 10; i++) {
    if (bit[i] == 1) {
      OR |= (1 << i);
    }
    if (bit[i] == 2) {
      XOR |= (1 << i);
    }
    if (bit[i] != 0) {
      AND |= (1 << i);
    }
  }
  cout << 3 << '\n';
  cout << '|' << ' ' << OR << '\n';
  cout << '&' << ' ' << AND << '\n';
  cout << '^' << ' ' << XOR << '\n';
}
/**
 *  1 = bit is 1
 *  0 = bit is 0
 * -1 = initial status
 *  2 = bit is flipped
**/


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <bitset>
#include <map>

#define Rep(i, n) for (register int i = 1; i <= n; ++ i)
#define Rep0(i, n) for (register int i = 0; i <= n; ++ i)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)
#define v edge[i].to

using namespace std;

char s[2];

int main()
{
	//freopen("a.in", "r", stdin);
	int n, s0 = 0, s1 = 0, ss = 1023;
	scanf("%d", &n);
	Rep(i, n) {
		int x;
		scanf("%s%d", s, &x);
		if (s[0] == '|') s0 &= (ss - x), s1 |= x;
		else if (s[0] == '&') x = ss - x, s1 &= (ss - x), s0 |= x;
		else {
			int tmp0 = x & s0, tmp1 = x & s1;
			s0 = s0 - tmp0 + tmp1, s1 = s1 - tmp1 + tmp0;
			//printf("%d %d\n", tmp0, tmp1);
		}
	}
	printf("2\n");
	printf("| %d\n", s1);
	s0 = ss - s0;
	printf("& %d\n", s0);

	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <bitset>
#include <map>

#define Rep(i, n) for (register int i = 1; i <= n; ++ i)
#define Rep0(i, n) for (register int i = 0; i <= n; ++ i)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)
#define v edge[i].to

using namespace std;

char s[2];

int main()
{
	//freopen("a.in", "r", stdin);
	int n, s0 = 0, s1 = 0, ss = 1023, s2 = 0;
	scanf("%d", &n);
	Rep(i, n) {
		int x;
		scanf("%s%d", s, &x);
		if (s[0] == '|') s0 &= (ss - x), s1 |= x;
		else if (s[0] == '&') x = ss - x, s1 &= (ss - x), s0 |= x;
		else {
			int tmp0 = x & s0, tmp1 = x & s1;
			s0 = s0 - tmp0 + tmp1, s1 = s1 - tmp1 + tmp0;
			s2 ^= x;
			//printf("%d %d\n", tmp0, tmp1);
		}
	}
	printf("2\n");
	printf("| %d\n", s1);
	s0 = ss - s0;
	printf("& %d\n", s0);
	printf("^ %d\n", s2 & (ss - ((ss - s0) | s1)));

	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <bitset>
#include <map>

#define Rep(i, n) for (register int i = 1; i <= n; ++ i)
#define Rep0(i, n) for (register int i = 0; i <= n; ++ i)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)
#define v edge[i].to

using namespace std;

char s[2];

int main()
{
	//freopen("a.in", "r", stdin);
	int n, s0 = 0, s1 = 0, ss = 1023, s2 = 0;
	scanf("%d", &n);
	Rep(i, n) {
		int x;
		scanf("%s%d", s, &x);
		if (s[0] == '|') s0 &= (ss - x), s1 |= x;
		else if (s[0] == '&') x = ss - x, s1 &= (ss - x), s0 |= x;
		else {
			int tmp0 = x & s0, tmp1 = x & s1;
			s0 = s0 - tmp0 + tmp1, s1 = s1 - tmp1 + tmp0;
			s2 ^= x;
			//printf("%d %d\n", tmp0, tmp1);
		}
	}
	printf("3\n");
	printf("| %d\n", s1);
	s0 = ss - s0;
	printf("& %d\n", s0);
	printf("^ %d\n", s2 & (ss - ((ss - s0) | s1)));

	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <bitset>
#include <map>

#define Rep(i, n) for (register int i = 1; i <= n; ++ i)
#define Rep0(i, n) for (register int i = 0; i <= n; ++ i)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)
#define v edge[i].to

using namespace std;

char s[2];

int main()
{
	//freopen("a.in", "r", stdin);
	int n, s0 = 0, s1 = 0, ss = 1024;
	scanf("%d", &n);
	Rep(i, n) {
		int x;
		scanf("%s%d", s, &x);
		if (s[0] == '|') s0 &= (ss - x), s1 |= x;
		if (s[0] == '&') x = ss - x, s1 &= (ss - x), s0 |= x;
		else {
			int tmp0 = x & s0, tmp1 = x & s1;
			s0 = s0 - tmp0 + tmp1, s1 = s1 - tmp1 + tmp0;
		}
	}
	printf("2\n");
	printf("| %d\n", s1);
	s0 = ss - s0;
	printf("& %d\n", s0);

	return 0;
}


#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <bitset>
#include <map>

#define Rep(i, n) for (register int i = 1; i <= n; ++ i)
#define Rep0(i, n) for (register int i = 0; i <= n; ++ i)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define mp(a, b) make_pair(a, b)
#define v edge[i].to

using namespace std;

char s[2];

int main()
{
	//freopen("a.in", "r", stdin);
	int n, s0 = 0, s1 = 0, ss = 1024;
	scanf("%d", &n);
	Rep(i, n) {
		int x;
		scanf("%s%d", s, &x);
		if (s[0] == '|') s0 &= (ss - x), s1 |= x;
		else if (s[0] == '&') x = ss - x, s1 &= (ss - x), s0 |= x;
		else {
			int tmp0 = x & s0, tmp1 = x & s1;
			s0 = s0 - tmp0 + tmp1, s1 = s1 - tmp1 + tmp0;
			//printf("%d %d\n", tmp0, tmp1);
		}
	}
	printf("2\n");
	printf("| %d\n", s1);
	s0 = ss - s0;
	printf("& %d\n", s0);

	return 0;
}


#include <stdio.h>
#include <cassert>
#include "bits/stdc++.h"

typedef long long ll;
typedef long double ld;
using namespace std;
const int maxN = 100500;
vector<pair<int,int>> numb[15];
char c[3];
int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0; i<n; i++)
    {

        int x;
        scanf("%s %d",c,&x);
        int type;
        if(c[0]=='&')type=2;
        else if(c[0]=='|')type=1;
        else if(c[0]=='^')type=0;
        int l =0;
        while(x>0)
        {
            numb[l].push_back(make_pair(type,x&1));
            x>>=1;
            l++;
        }
    }
    int or2=-1;
    int xor2=-1;
    int and2=-1;
    for(int i=0; i<10; i++)
    {
        int if0 = 0;
        int if1 = 1;
        for(pair<int,int> op:numb[i])
        {
            int x = op.second;
            int type = op.first;
            if(type==0)
            {
                if0^=x;
                if1^=x;
            }
            else if(type==1)
            {
                if0|=x;
                if1|=x;
            }
            else if(type==2)
            {
                if0&=x;
                if1&=x;
            }
        }
        int l = (1<<i);
        if(if0==0 && if1==0)
        {

        }
        else if(if0==1 && if1==1)
        {
            if(or2!=-1)or2+=l;
            else or2=l;
        }
        else if(if0==1 && if1==0)
        {
            if(xor2!=-1)xor2+=l;
            else xor2=l;
        }
        else if(if0==0 && if1==1)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
        }
    }
    int p = 0;
    if(or2!=-1)p++;
    if(xor2!=-1)p++;
    if(and2!=-1)p++;
    printf("%d\n",p);
    if(or2!=-1)printf("| %d\n",or2);
    if(xor2!=-1)printf("^ %d\n",xor2);
    if(and2!=-1)printf("& %d\n",and2);
}


#include <stdio.h>
#include <cassert>
#include "bits/stdc++.h"

typedef long long ll;
typedef long double ld;
using namespace std;
const int maxN = 100500;
vector<pair<int,int>> numb[15];
char c[3];
int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0; i<n; i++)
    {

        int x;
        scanf("%s %d",c,&x);
        int type;
        if(c[0]=='&')type=2;
        else if(c[0]=='|')type=1;
        else if(c[0]=='^')type=0;
        for(int i=0;i<10;i++)
        {
            numb[i].push_back(make_pair(type,x&1));
            x>>=1;
        }
    }
    int or2=-1;
    int xor2=-1;
    int and2=0;
    for(int i=0; i<10; i++)
    {
        int if0 = 0;
        int if1 = 1;
        for(pair<int,int> op:numb[i])
        {
            int x = op.second;
            int type = op.first;
            if(type==0)
            {
                if0^=x;
                if1^=x;
            }
            else if(type==1)
            {
                if0|=x;
                if1|=x;
            }
            else if(type==2)
            {
                if0&=x;
                if1&=x;
            }
        }
        //printf("%d. Should 0 have: %d   Should 1 have: %d\n",i,if0,if1);
        int l = (1<<i);
        if(if0==0 && if1==0)
        {

        }
        else if(if0==1 && if1==1)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
            if(or2!=-1)or2+=l;
            else or2=l;
        }
        else if(if0==1 && if1==0)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
            if(xor2!=-1)xor2+=l;
            else xor2=l;
        }
        else if(if0==0 && if1==1)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
        }
    }
    int p = 0;
    if(or2!=-1)p++;
    if(xor2!=-1)p++;
    if(and2!=-1)p++;
    printf("%d\n",p);
    if(or2!=-1)printf("| %d\n",or2);
    if(xor2!=-1)printf("^ %d\n",xor2);
    if(and2!=-1)printf("& %d\n",and2);
}


#include <stdio.h>
#include <cassert>
#include "bits/stdc++.h"

typedef long long ll;
typedef long double ld;
using namespace std;
const int maxN = 100500;
vector<pair<int,int>> numb[15];
char c[3];
int main()
{
    int n;
    scanf("%d",&n);

    for(int i=0; i<n; i++)
    {

        int x;
        scanf("%s %d",c,&x);
        int type;
        if(c[0]=='&')type=2;
        else if(c[0]=='|')type=1;
        else if(c[0]=='^')type=0;
        for(int i=0;i<10;i++)
        {
            numb[i].push_back(make_pair(type,x&1));
            x>>=1;
        }
    }
    int or2=-1;
    int xor2=-1;
    int and2=-1;
    for(int i=0; i<10; i++)
    {
        int if0 = 0;
        int if1 = 1;
        for(pair<int,int> op:numb[i])
        {
            int x = op.second;
            int type = op.first;
            if(type==0)
            {
                if0^=x;
                if1^=x;
            }
            else if(type==1)
            {
                if0|=x;
                if1|=x;
            }
            else if(type==2)
            {
                if0&=x;
                if1&=x;
            }
        }
        //printf("%d. Should 0 have: %d   Should 1 have: %d\n",i,if0,if1);
        int l = (1<<i);
        if(if0==0 && if1==0)
        {

        }
        else if(if0==1 && if1==1)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
            if(or2!=-1)or2+=l;
            else or2=l;
        }
        else if(if0==1 && if1==0)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
            if(xor2!=-1)xor2+=l;
            else xor2=l;
        }
        else if(if0==0 && if1==1)
        {
            if(and2!=-1)and2+=l;
            else and2=l;
        }
    }
    int p = 0;
    if(or2!=-1)p++;
    if(xor2!=-1)p++;
    if(and2!=-1)p++;
    printf("%d\n",p);
    if(or2!=-1)printf("| %d\n",or2);
    if(xor2!=-1)printf("^ %d\n",xor2);
    if(and2!=-1)printf("& %d\n",and2);
}


#include <stdio.h>
#include <cassert>
#include "bits/stdc++.h"

typedef long long ll;
typedef long double ld;
using namespace std;
const int maxN = 100500;
char c[3];
int main()
{
    int n;
    scanf("%d",&n);
    int r = -1;
    int xr = -1;
    int ad = -1;
    for(int i=0;i<n;i++){

        int x;
        scanf("%s %d",c,&x);
        if(c[0]=='^'){
                if(xr!=-1)xr^=x;
                else xr=x;
        }
        else if(c[0]=='|') {
                if(r!=-1)r|=x;
                else r=x;
        }
        else if(c[0]=='&') {
                if(ad!=-1)ad&=x;
                else ad=x;
        }
    }
    int p = 0;
    if(r!=-1)p++;
    if(xr!=-1)p++;
    if(ad!=-1)p++;
    printf("%d\n",p);
    if(r!=-1)printf("| %d\n",r);
    if(xr!=-1)printf("^ %d\n",xr);
    if(ad!=-1)printf("& %d\n",ad);
}


#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,n) for (int i=a;i<n;i++)
#define rfl(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }
/*std::cout << std::fixed;
std::cout << std::setprecision(2);*/
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    int n=1023;
    int x1=1023;
    char c;
    int a;
    while(x--)
    {

                cin >> c >> a;
                if(c=='&')
                {
                    n= n&a;
                }
                else if(c=='|')
                {
                    n= n|a;
                }
                else
                {
                    n = n^a;
                }
    }
    cout << 1 << "\n";
    cout << "& " << 1021;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,n) for (int i=a;i<n;i++)
#define rfl(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }
/*std::cout << std::fixed;
std::cout << std::setprecision(2);*/
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    int n=2;
    int x1=1023;
    char c;
    int a;
    while(x--)
    {

                cin >> c >> a;
                if(c=='&')
                {
                    n= n&a;
                }
                else if(c=='|')
                {
                    n= n|a;
                }
                else
                {
                    n = n^a;
                }
    }
    cout << 2 << "\n";
    cout << "| " << 1 << "\n";
    cout << "& " << 1021;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,n) for (int i=a;i<n;i++)
#define rfl(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }
/*std::cout << std::fixed;
std::cout << std::setprecision(2);*/
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    int n1=0;
    int n2=1023;
    char c;
    int a;
    fl(i,0,x)
    {

                cin >> c >> a;
                if(c=='&')
                {
                    n1= n1&a;
                    n2= n2&a;
                }
                else if(c=='|')
                {
                    n1= n1|a;
                    n2 = n2|a;
                }
                else
                {
                    n1 = n1^a;
                    n2 = n2^a;

          }
    }
    vector<int>v1;
    vector<int>v2;
    vector<int>v3;
    vector<int>v4;
    vector<int>v5;
    while(n1)
    {
        v1.pb(n1%2);
        n1 = n1/2;
    }
    while(v1.size()!=10)
    {
        v1.pb(0);
    }
    while(n2)
    {
        v2.pb(n2%2);
        n2 = n2/2;
    }
    while(v2.size()!=10)
    {
        v2.pb(0);
    }
    for(int i=9;i>=0;i--)
    {
        if(v1[i]==0&&v2[i]==0)
        {
             v3.pb(0);
             v4.pb(0);
             v5.pb(0);
        }
        if(v1[i]==0&&v2[i]==1)
        {
            v3.pb(0);
            v4.pb(1);
            v5.pb(0);
        }
        if(v1[i]==1&&v2[i]==0)
        {
            v3.pb(0);
            v4.pb(1);
            v5.pb(1);
        }
        if(v1[i]==1&&v2[i]==1)
        {
            v3.pb(1);
            v4.pb(1);
            v5.pb(0);
        }
    }
    cout << 3 << "\n";
    int n=0;
    reverse(v3.begin(),v3.end());
    reverse(v4.begin(),v4.end());
    reverse(v5.begin(),v5.end());
    fl(i,0,10)
    {
        if(v3[i]==1){
        n = n+pow(2,i);}
    }
    cout << "| " << n << "\n";
    n=0;
    fl(i,0,10)
    {
        if(v4[i]==1)
        {
            n = n+pow(2,i);
        }
    }
    cout << "& " << n << "\n";
    n=0;
    fl(i,0,10)
    {
        if(v5[i]==1)
        {
            n = n+pow(2,i);
        }
    }
    cout << "^ " << n;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,n) for (int i=a;i<n;i++)
#define rfl(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }
/*std::cout << std::fixed;
std::cout << std::setprecision(2);*/
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int x;
    cin >> x;
    int n1=0;
    int n2=1023;
    char c;
    int a;
    fl(i,0,x)
    {

                cin >> c >> a;
                if(c=='&')
                {
                    n1= n1&a;
                    n2= n2&a;
                }
                else if(c=='|')
                {
                    n1= n1|a;
                    n2 = n2|a;
                }
                else
                {
                    n1 = n1^a;
                    n2 = n2^a;
                }
    }
    cout << 2 << "\n";
    cout << "| " << n1 << "\n";
    cout << "& " << n2;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  int n;
  cin >> n;
  int x0 = 0, x1 = 1023;
  while (n--) {
    char op;
    int a;
    cin >> op >> a;
    if (op == '&') {x0 &= a; x1 &= a;}
    else if (op == '^') {x0 ^= a; x1 ^= a;}
    else {x0 |= a; x1 |= a;}
  }

  int ornum = 0, xornum = 0;

  for (int x = 1; x < 1024; x <<= 1) {
    int y1 = x1 & x;
    int y0 = x0 & x;
    if ((y0 != 0 and y1 != 0) or (y0 == 0 and y1 == 0) ) ornum |= x;
    if (y1 == 0) xornum |= x;
  }

  cout << 2 << endl;
  cout << "^ " << xornum << endl;
  cout << "| " << ornum << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  int x0 = 0, x1 = 1023;
  while (n--) {
    char op;
    int a;
    cin >> op >> a;
    if (op == '&') {x0 &= a; x1 &= a;}
    else if (op == '^') {x0 ^= a; x1 ^= a;}
    else {x0 |= a; x1 |= a;}
  }

  int ornum = 0, xornum = 0;

  for (int x = 1; x < 1024; x <<= 1) {
    int y1 = x1 & x;
    int y0 = x0 & x;
    if (y0 == y1) ornum |= x;
    if (y1 == 0) xornum |= x;
  }

  cout << 2 << endl;
  cout << "| " << ornum << endl;
  cout << "^ " << xornum << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

int program (int x, vector<char> & op, vector<int> &a) {
  int n = op.size();
  for (int i = 0; i < n; i++) {
    if (op[i] == '&') x &= a[i];
    else if (op[i] == '^') x ^= a[i];
    else x |= a[i];
  }
  return x;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  int n;
  cin >> n;
  vector<char> op(n);
  vector<int> a(n);
  for (int i = 0 ; i < n; i++)
    cin >> op[i] >> a[i];

  int andnum = 1023;
  int ornum = 0, xornum = 0;

  for (int i = 0; i < 10; i++) {
    int x = 1<<i;
    int y1 = program(x, op, a) & x;
    int y0 = program(0, op, a) & x;
    if (y0 == 0 and y1 == 0) andnum &= (1023-x);
    if (y0 == 1 and y1 == 1) ornum |= x;
    if (y0 == 1 and y1 == 0) xornum |= x;
  }
//   vector<char> opalt({'&','^','|'});
//   vector<int> aalt({andnum, xornum, ornum});
//
//   for (int i = 0; i < 1024; i++)
//     if (program(i, op, a) != program(i, opalt, aalt)) cerr << "Cagada\n";

  cout << 3 << endl;
  cout << "& " << andnum << endl;
  cout << "^ " << xornum << endl;
  cout << "| " << ornum << endl;

  return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

int program (int x, vector<char> & op, vector<int> &a) {
  int n = op.size();
  for (int i = 0; i < n; i++) {
    if (op[i] == '&') x &= a[i];
    else if (op[i] == '^') x ^= a[i];
    else x |= a[i];
  }
  return x;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.precision(20);
  int n;
  cin >> n;
  vector<char> op(n);
  vector<int> a(n);
  for (int i = 0 ; i < n; i++)
    cin >> op[i] >> a[i];

  int andnum = 1023;
  int ornum = 0, xornum = 0;

  for (int i = 0; i < 10; i++) {
    int x = 1<<i;
    int y1 = program(x, op, a) & x;
    int y0 = program(0, op, a) & x;
    if (y0 == 0 and y1 == 0) andnum &= (1023-x);
    if (y0 != 0 and y1 != 0) ornum |= x;
    if (y0 != 0 and y1 == 0) xornum |= x;
  }

  cout << 3 << endl;
  cout << "& " << andnum << endl;
  cout << "^ " << xornum << endl;
  cout << "| " << ornum << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353

void solve() {
    int n;
    cin>>n;
    int a=0,b=1023;
    for(int i=0;i<n;i++){
        char cc;int x;
        cin>>cc>>x;
        if(cc=='|'){
            a|=x;b|=x;
        }
        else if(cc=='&'){
            a&=x;b&=x;
        }
        else {
            a^=x;b^=x;
        }
    }
        cout<<"2\n& "<<(a^b)<<endl;
        cout<<"^ "<<a<<endl;
}
int32_t main() {
	int t=1;
// 	cin>>t;
while(t--){
// cout<<"Case"<<t<<endl;
solve();
}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353

void solve() {
    int n;
    cin>>n;
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        char cc;int x;
        cin>>cc>>x;
        if(cc=='|')a|=x;
        else if(cc=='&'){
            b=min(b,x);
            if(x==1)b=x;
        }
        else c^=x;
    }
    int x=0;
    if(a!=0)x++;
    if(b!=0)x++;
    if(c!=0)x++;
    cout<<x<<endl;
    if(a!=0)cout<<"| "<<a<<endl;
    if(b!=0)cout<<"& "<<b<<endl;if(c!=0)cout<<"^ "<<c<<endl;
}
int32_t main() {
	int t=1;
// 	cin>>t;
while(t--){
// cout<<"Case"<<t<<endl;
solve();
}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353

void solve() {
    int n;
    cin>>n;
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        char cc;int x;
        cin>>cc>>x;
        if(cc=='|')a|=x;
        else if(cc=='&'){
            b=min(b,x);
            if(b==0)b=x;
        }
        else c^=x;
    }
    int x=0;
    if(a!=0)x++;
    if(b!=0)x++;
    if(c!=0)x++;
    cout<<x<<endl;
    if(a!=0)cout<<"| "<<a<<endl;
    if(b!=0)cout<<"& "<<b<<endl;if(c!=0)cout<<"^ "<<c<<endl;
}
int32_t main() {
	int t=1;
// 	cin>>t;
while(t--){
// cout<<"Case"<<t<<endl;
solve();
}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    int n, fn = 0, fn1 = 1023;
    scanf("%d", &n);
    while(n--){
      char op;
      int x;
      cin >> op >> x;
      if(op == '|')fn |= x, fn1 |= x;
      if(op == '^')fn ^= x, fn1 ^= x;
      if(op == '&')fn &= x, fn1 &= x;
    }
    puts("2");
    for(int i = 0; i<=1023; ++i){
      for(int j = 0; j<=1023; ++j){
         if((i ^ j) == fn && (((1023 | i) ^ j) == fn1)){
          return printf("| %d\n^ %d\n", i, j), 0;
         }
      }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    int n;
    map<char, int> ops;
    scanf("%d", &n);
    ops['&'] = ops['^'] = ops['|'] = -1;
    while(n--){
      char op;
      int x;
      cin >> op >> x;
      if(op == '|'){
        if(ops[op] == -1)ops[op] = x;
        else ops[op] |= x;
      }
      if(op == '^'){
        if(ops[op] == -1)ops[op] = x;
        else ops[op] ^= x;
      }
      if(op == '&'){
        if(ops[op] == -1)ops[op] = x;
        else ops[op] &= x;
      }
    }
    vector<pair<char,int>> an;
    for(auto i: ops){
      if(i.second > 0)an.push_back({i.first, i.second});
    }
    printf("%d\n", an.size());
    for(auto i: an)printf("%c %d\n", i.first, i.second);
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    int n, fn;
    scanf("%d", &n);
    while(n--){
      char op;
      int x;
      cin >> op >> x;
      if(op == '|')fn |= x;
      if(op == '^')fn ^= x;
      if(op == '&')fn &= x;
    }
    puts("2");
    for(int i = 0; i<=1023; ++i){
      for(int j = 0; j<=1023; ++j){
         if((0 | i) ^ j == fn){
          return printf("| %d\n^ %d\n", i, j), 0;
         }
      }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    int n, fn = 0;
    scanf("%d", &n);
    while(n--){
      char op;
      int x;
      cin >> op >> x;
      if(op == '|')fn |= x;
      if(op == '^')fn ^= x;
      if(op == '&')fn &= x;
    }
    puts("2");
    for(int i = 0; i<=1023; ++i){
      for(int j = 0; j<=1023; ++j){
         if(i ^ j == fn){
          return printf("| %d\n^ %d\n", i, j), 0;
         }
      }
    }
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & 1 << j){
                    lock |= 1 << j;
                    bt1 |= 1 << j;
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & 1 << j) == 0){
                    lock |= 1 << j;
                    if(bt1 & 1 << j) bt1 ^= 1 << j;
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & 1 << j){
                    if(lock & 1 << j) bt1 ^= 1 << j;
                    bt2 ^= 1 << j;
                }
        }
    }
    int b1 = (1 << 10) - 1,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & 1 << i){
            if(bt1 & 1 << i) b2 += 1 << i;
            else b1 -= 1 << i;
        }
        else if(bt2 & 1 << i) b3 += 1 << i;
    }
    vector<pair<char,int> >ans;
    if(b1 != 1023) ans.push_back(make_pair('&',b1));
    if(b2 != 0) ans.push_back(make_pair('|',b2));
    if(b3 |= 0) ans.push_back(make_pair('^',b3));
    printf("%d\n",ans.size());
    for(int i = 0;i < ans.size();i++)
        printf("%c %d\n",ans[i].X,ans[i].Y);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= (1 << j);
                    bt1 |= (1 << j);
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= (1 << j);
                    if(bt1 & (1 << j)) bt1 ^= (1 << j);
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= (1 << j);
                    bt2 ^= (1 << j);
                }
        }
        printf("%d %d\n",bt1,lock);
    }
    int b1 = 1023,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += (1 << i);
            else b1 -= (1 << i);
        }
        else if(bt2 & (1 << i)) b3 += (1 << i);
    }
    puts("3");
    printf("& %d\n| %d\n^ %d\n",b1,b2,b3);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= (1 << j);
                    bt1 |= (1 << j);
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= (1 << j);
                    if(bt1 & (1 << j)) bt1 ^= (1 << j);
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= (1 << j);
                    bt2 ^= (1 << j);
                }
        }
        printf("%d %d\n",bt1,lock);
    }
    int b1 = 1023,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += (1 << i);
            else b1 -= (1 << i);
        }
        else if(bt2 & (1 << i)) b3 += (1 << i);
    }
    puts("3");
    printf("& %d\n| %d\n^ %d\n",b1,b2,b3);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
char o[4];
int main(){
    //debug;
    int lock = 0,bt1 = 0,bt2 = 0,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= (1 << j);
                    bt1 |= (1 << j);
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= (1 << j);
                    if(bt1 & (1 << j)) bt1 ^= (1 << j);
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= (1 << j);
                    bt2 ^= (1 << j);
                }
        }
    }
    int b1 = 1023,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += (1 << i);
            else b1 -= (1 << i);
        }
        else if(bt2 & (1 << i)) b3 += (1 << i);
    }
    puts("3");
    printf("& %d\n| %d\n^ %d\n",b1,b2,b3);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= 1 << j;
                    bt1 |= 1 << j;
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= 1 << j;
                    if(bt1 & (1 << j)) bt1 ^= 1 << j;
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= 1 << j;
                    bt2 ^= 1 << j;
                }
        }
    }
    int b1 = (1 << 10) - 1,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += 1 << i;
            else b1 -= 1 << i;
        }
        else if(bt2 & (1 << i)) b3 += 1 << i;
    }
    vector<pair<char,int> >ans;
    if(b1 != 1023) ans.push_back(make_pair('&',b1));
    if(b2 != 0) ans.push_back(make_pair('|',b2));
    if(b3 |= 0) ans.push_back(make_pair('^',b3));
    printf("%d\n",ans.size());
    for(int i = 0;i < ans.size();i++)
        printf("%c %d\n",ans[i].X,ans[i].Y);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= 1 << j;
                    bt1 |= 1 << j;
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= 1 << j;
                    if(bt1 & (1 << j)) bt1 ^= 1 << j;
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= 1 << j;
                    bt2 ^= 1 << j;
                }
        }
    }
    int b1 = 1023,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += 1 << i;
            else b1 -= 1 << i;
        }
        else if(bt2 & (1 << i)) b3 += 1 << i;
    }
    puts("3");
    printf("& %d\n| %d\n^ %d\n",b1,b2,b3);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
char o[4];
int main(){
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    printf("A: %d\n",lock);
                    lock |= (1 << j);
                    printf("B: %d\n",lock);
                    bt1 |= (1 << j);
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= (1 << j);
                    if(bt1 & (1 << j)) bt1 ^= (1 << j);
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= (1 << j);
                    bt2 ^= (1 << j);
                }
        }
    }
    int b1 = 1023,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += (1 << i);
            else b1 -= (1 << i);
        }
        else if(bt2 & (1 << i)) b3 += (1 << i);
    }
    puts("3");
    printf("& %d\n| %d\n^ %d\n",b1,b2,b3);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= 1 << j;
                    bt1 |= 1 << j;
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= 1 << j;
                    if(bt1 & 1 << j) bt1 ^= 1 << j;
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & 1 << j) bt1 ^= 1 << j;
                    bt2 ^= 1 << j;
                }
        }
    }
    int b1 = (1 << 10) - 1,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += 1 << i;
            else b1 -= 1 << i;
        }
        else if(bt2 & (1 << i)) b3 += 1 << i;
    }
    vector<pair<char,int> >ans;
    if(b1 != 1023) ans.push_back(make_pair('&',b1));
    if(b2 != 0) ans.push_back(make_pair('|',b2));
    if(b3 |= 0) ans.push_back(make_pair('^',b3));
    printf("%d\n",ans.size());
    for(int i = 0;i < ans.size();i++)
        printf("%c %d\n",ans[i].X,ans[i].Y);
}


# include <bits/stdc++.h>
# define X first
# define Y second
# define mem(a,b) memset(a,b,sizeof(a))
# define lb(x) (x & -x)
# define debug freopen("r.txt","r",stdin)
# define pi pair<int,int>
# define ABS(x) (x < 0 ? (-(x)) : (x))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int N = 54;
int main(){
    char o[4];
    //debug;
    int lock,bt1,bt2,n,x;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%s %d",o,&x);
        if(o[0] == '|'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    lock |= (1 << j);
                    bt1 |= (1 << j);
                }
        }
        else if(o[0] == '&'){
            for(int j = 0;j < 10;j++)
                if((x & (1 << j)) == 0){
                    lock |= (1 << j);
                    if(bt1 & (1 << j)) bt1 ^= (1 << j);
                }
        }
        else if(o[0] == '^'){
            for(int j = 0;j < 10;j++)
                if(x & (1 << j)){
                    if(lock & (1 << j)) bt1 ^= (1 << j);
                    bt2 ^= (1 << j);
                }
        }
    }
    int b1 = 1023,b2 = 0,b3 = 0;
    for(int i = 0;i < 10;i++){
        if(lock & (1 << i)){
            if(bt1 & (1 << i)) b2 += (1 << i);
            else b1 -= (1 << i);
        }
        else if(bt2 & (1 << i)) b3 += (1 << i);
    }
    puts("3");
    printf("& %d\n| %d\n^ %d\n",b1,b2,b3);
}


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,o = 0 ,x = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int a;
        scanf(" %c%d",&ch,&a);

        if(ch == '|')
            o |= a;
        else if(ch == '&')
            an &= a;
        else
            x ^= a;
    }

    printf("3\n");
    printf("& %d\n",an);
    printf("| %d\n",o);
    printf("^ %d\n",x);
    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,oR = 0 ,xo = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int x;
        scanf(" %c%d",&ch,&x);

        if(ch == '|') {
            oR |= x;
        }
        else if(ch == '&') {
            an &= x;
        }
        else {
            xo ^= x;
        }
    }

    printf("3\n");
    printf("| %d\n",oR);
    printf("^ %d\n",xo);
    printf("& %d\n",an);

    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,oR = 0 ,xo = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int x;
        scanf(" %c%d",&ch,&x);

        if(ch == '|') {
            xo &= ~x;
            oR |= x;
        }
        else if(ch == '&') {
            an &= x;
        }
        else {
            xo ^= x;
        }
    }

    printf("3\n");
    printf("| %d\n",oR);
    printf("^ %d\n",xo);
    printf("& %d\n",an);

    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,oR = 0 ,xo = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int x;
        scanf(" %c%d",&ch,&x);

        if(ch == '|') {
            xo &= ~x;
            an |= x;
            oR |= x;
        }
        else if(ch == '&') {
            an &= x;
            xo &= ~an;
        }
        else {
            xo ^= x;
        }
    }

    printf("3\n");
    printf("| %d\n",oR);
    printf("& %d\n",an);
    printf("^ %d\n",xo);

    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,oR = 0 ,xo = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int x;
        scanf(" %c%d",&ch,&x);

        if(ch == '|') {
            xo &= ~x;
            an |= x;
            oR |= x;
        }
        else if(ch == '&') {
            an &= x;
        }
        else {
            xo ^= x;
            an |= xo;
        }
    }

    printf("3\n");
    printf("| %d\n",oR);
    printf("^ %d\n",xo);
    printf("& %d\n",an);

    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,oR = 0 ,xo = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int x;
        scanf(" %c%d",&ch,&x);

        if(ch == '|') {
            xo &= ~x;
            an |= x;
            oR |= x;
        }
        else if(ch == '&') {
            an &= x;
            xo &= x;
        }
        else {
            xo ^= x;
        }
    }

    printf("3\n");
    printf("| %d\n",oR);
    printf("& %d\n",an);
    printf("^ %d\n",xo);

    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

int main()
{
    int n;
    int an = 1023,oR = 0 ,xo = 0;
    scanf("%d",&n);
    lp(i, 1, n) {
        char ch;
        int x;
        scanf(" %c%d",&ch,&x);

        if(ch == '|') {
            xo &= ~x;
            an |= x;
            oR |= x;
        }
        else if(ch == '&') {
            an &= x;
            xo &= ~x;
        }
        else {
            xo ^= x;
        }
    }

    printf("3\n");
    printf("| %d\n",oR);
    printf("& %d\n",an);
    printf("^ %d\n",xo);

    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define bp push_back
#define pause; system("pause");
#define mp make_pair
const int N=1e5+10;
const double eps=1e-9;
const int inf=1e9;
char a[N];
main(){

    int n;
    int res=0;
    bool orr=0,andd=0,xr=0;
    cin>>n;
    for(int i=0;i<n;i++){
        char c;
        int x;
        cin>>c>>x;
        if(c=='|'){
            res|=x;
            orr=1;
        }
        else if(c=='&'){
            if(!res)res=x;
            andd=1;
        }
        else{
            xr=1;
            res^=x;
        }
    }
    if(!res){
        cout<<0;
        return 0;
    }
    if(andd && orr && xr){
        cout<<"3"<<endl;
        cout<<"& 0"<<endl;
        cout<<"^ 0"<<endl;
        cout<<"| "<<res;
    }
    else if(andd && orr){
        cout<<2<<endl;
        cout<<"& 0"<<endl;
        cout<<"| "<<res;
    }
    else if(andd && xr){
        cout<<2<<endl;
        cout<<"& "<<res<<endl;
        cout<<"^ 0";
    }
    else if(orr && xr){
        cout<<2<<endl;
        cout<<"^ 0"<<endl;
        cout<<"| "<<res;
    }
    else if(orr){
        cout<<1<<endl<<"| "<<res;
    }
    else if(andd){
        cout<<1<<endl<<"& "<<res;
    }
    else if(xr){
        cout<<1<<endl<<"^ "<<res;

    }

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define bp push_back
#define pause; system("pause");
#define mp make_pair
const int N=1e5+10;
const double eps=1e-9;
const int inf=1e9;
char a[N];
int biton[12],bitof[12],bitflip[12];
main(){

    int n;
    int res=0;
    cin>>n;
    for(int i=0;i<n;i++){
        char c;
        int x;
        cin>>c>>x;
        if(c=='|'){
            for(int bit=0;bit<10;bit++){
                if(x&(1<<bit)){
                    biton[bit]=1;
                    bitof[bit]=bitflip[bit]=0;
                }
            }
        }
        else if(c=='&'){
            for(int bit=0;bit<10;bit++){
                if(!(x&(1<<bit))){
                    bitof[bit]=1;
                    biton[bit]=bitflip[bit]=0;
                }
            }
        }
        else{
            for(int bit=0;bit<10;bit++){
                if((x&(1<<bit))){
                    if(biton[bit])swap(bitof[bit],biton[bit]);
                    else if(bitof[bit])swap(bitof[bit],biton[bit]);
                    else bitflip[bit]^=1;
                }
            }
        }
    }
    int orr=0,andd=1<<10,xr=0;
    --andd;
    for(int i=0;i<10;i++){
        if(biton[i])orr|=(1<<i);
        if(bitof[i])andd-=(1<<i);
        if(bitflip[i])xr^=(1<<i);
    }
    cout<<3<<endl<<"| "<<orr<<endl<<"& "<<andd<<endl<<"^ "<<xr;

}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define bp push_back
#define pause; system("pause");
#define mp make_pair
const int N=1e5+10;
const double eps=1e-9;
const int inf=1e9;
char a[N];
main(){

    int n;
    int res=0;
    bool orr=0,andd=0,xr=0;
    cin>>n;
    for(int i=0;i<n;i++){
        char c;
        int x;
        cin>>c>>x;
        if(c=='|'){
            res|=x;
            orr=1;
        }
        else if(c=='&'){
            if(!res)res=x;
            andd=1;
        }
        else{
            xr=1;
            if(!res)res=x;
            else res^=x;
        }
    }
    if(!res){
        cout<<0;
        return 0;
    }
    if(andd && orr && xr){
        cout<<"3"<<endl;
        cout<<"| "<<res<<endl;
        cout<<"& 1"<<endl;
        cout<<"^ 0"<<endl;
    }
    else if(andd && orr){
        cout<<2<<endl;
        cout<<"| "<<res;
        cout<<"& 1"<<endl;
    }
    else if(andd && xr){
        cout<<2<<endl;
        cout<<"& "<<res<<endl;
        cout<<"^ 0";
    }
    else if(orr && xr){
        cout<<2<<endl;
        cout<<"| "<<res<<endl;
        cout<<"^ 0"<<endl;
    }
    else if(orr){
        cout<<1<<endl<<"| "<<res;
    }
    else if(andd){
        cout<<1<<endl<<"& "<<res;
    }
    else if(xr){
        cout<<1<<endl<<"^ "<<res;

    }

}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a|=x, b&=(~x);
		if(s=="^") b^=x;
		if(s=="&") a&=x, b|=(~x);
	}
	puts("2");
	cout<<"| "<<a<<endl;
	cout<<"^ "<<b<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a|=x, b&=(~x);
		if(s=="^") b^=x;
		if(s=="&") a&=x, b|=(~x);
	}
	puts("3");
	cout<<"| "<<a<<endl;
	cout<<"^ "<<b<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

using INT = long long;

const int NN = 5e5+10;

char s[NN];
int a[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin >> n;
	for(int i=1; i<=n; i++) {
		scanf(" %c %d", s+i, a+i);
	}
	int sor = 0, sand = (1<<10)-1, sxor = 0;
	for(int i=0; i<10; i++) {
		int st1 = (1<<i);
		int st0 = 0;
		for(int j=1; j<=n; j++) {
			int x = 0;
			if((a[j]>>i)&1) x = (1<<i);
			if(s[j] == '|') st1 |= x, st0 |= x;
			if(s[j] == '&') st1 &= x, st0 &= x;
			if(s[j] == '^') st1 ^= x, st0 ^= x;
		}
		if(st1 == 1 and st0 == 1) {
			sor ^= (1<<i);
		}
		if(st1 == 0 and st0 == 1) {
			sxor ^= (1<<i);
		}
		if(st1 == 0 and  st0 == 0) {
			sand ^= (1<<i);
		}
	}
	cout << 3 << endl;
	cout << "|" << ' ' << sor << endl;
	cout << "&" << ' ' << sand << endl;
	cout << "^" << ' ' << sxor << endl;
}


#include<bits/stdc++.h>
#define x first
#define y second
#define NN 500100

using namespace std;
using INT=long long;
using pci=pair<char, int>;

const int N=1023;
pci p[NN];

char s[]={'&', '|', '^', };
int ans[20][2];
int val[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		char c;
		int x;
		scanf(" %c %d", &c, &x);
		p[i]=pci(c, x);
	}
	for(int i=0; i<10; i++) {
		for(int j=0; j<2; j++) {
			ans[i][j]=j;
			for(int k=1; k<=n; k++) {
				int tmp=p[k].y;
				int op=(tmp&(1<<i));
				if(op) op=1;
				if(p[k].x==s[0]) ans[i][j]=(ans[i][j]&op);
				if(p[k].x==s[1]) ans[i][j]=(ans[i][j]|op);
				if(p[k].x==s[2]) ans[i][j]^=op;
			}
		}
	}
	int x=0, y=0;
	for(int i=0; i<10; i++) {
		if(ans[i][0]==ans[i][1]) {
			x+=(1<<i);
			y+=(ans[i][0]^1)*(1<<i);
		}else {
			y+=(ans[i][0]^0)*(1<<i);
		}
	}
	cout<<2<<endl;
	cout<<s[1]<<" "<<x<<endl;
	cout<<s[2]<<" "<<y<<endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

using INT = long long;

const int NN = 5e5+10;

char s[NN];
int a[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin >> n;
	for(int i=1; i<=n; i++) {
		scanf(" %c %d", s+i, a+i);
	}
	int sor = 0, sand = (1<<10)-1, sxor = 0;
	for(int i=0; i<10; i++) {
		int st1 = (1<<i);
		int st0 = 0;
		for(int j=1; j<=n; j++) {
			int x = 0;
			if((a[j]>>i)&1) x = (1<<i);
			if(s[j] == '|') st1 |= x, st0 |= x;
			if(s[j] == '&') st1 &= x, st0 &= x;
			if(s[j] == '^') st1 ^= x, st0 ^= x;
		}
		if(st1 and st0) {
			sor ^= (1<<i);
		}
		if(!st1 and st0) {
			sxor ^= (1<<i);
		}
		if(st1 and  !st0) {
			sand ^= (1<<i);
		}
	}
	cout << 3 << endl;
	cout << "|" << ' ' << sor << endl;
	cout << "&" << ' ' << sand << endl;
	cout << "^" << ' ' << sxor << endl;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b = 1023;
int c = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a |= x;
		if(s=="&") b &= x;
		if(s=="^") c ^= x;
	}
	cout<<"| "<<a<<endl;
	cout<<"& "<<b<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b = 511;
int c = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a |= x;
		if(s=="&") b &= x;
		if(s=="^") c ^= x;
	}
	puts("3");
	cout<<"| "<<a<<endl;
	cout<<"& "<<b<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b =1023;
int c = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") b|=x, a|=x;
		if(s=="&") a&=x, b&=x;
		if(s=="^") a^=x, b^=x;
	}
	puts("2");
	cout<<"| "<<a<<endl;
	cout<<"& "<<b<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int NN = 501010;

int a = 0;
int b = 0;
int c = 0;

string s[NN];
int x[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>s[i]>>x[i];
	}

	for(int j=0; j<10; j++) {
		int u=0, v=1<<j;
		for(int i=1; i<=n; i++) {
			if(s[i]=="|") u|=x[i], v|=x[i];
			if(s[i]=="&") u&=x[i], v&=x[i];
			if(s[i]=="^") u^=x[i], v^=x[i];
		}
		u&=(1<<j); v&=(1<<j);
		if(!u && !v) continue;
		if(!u && v) b|=1<<j;
		if(u && v) c|=1<<j;
		if(u && !v) b|=1<<j, c|=1<<j;
	}
	puts("2");
	cout<<"& "<<b<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[27];
void AND(int d){
	for(int i=0;i<10;i++){
		if(d&(1<<i)) continue;
		a[i]=0;
	}
}
void OR(int d){
	for(int i=0;i<10;i++){
		if(d&(1<<i)) a[i]=1;
	}
}
void XOR(int d){
	for(int i=0;i<10;i++){
		if(d&(1<<i)) a[i]^=1;
	}
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	for(int i=0;i<=10;i++) a[i]=3;
	int n;scanf("%d",&n);
	while(n--){
		char c;int d;
		scanf(" %c",&c);scanf("%d",&d);
		if(c=='&') AND(d);
		if(c=='|') OR(d);
		if(c=='^') XOR(d);
	}
	int A=0,O=0,X=0;
	for(int i=0;i<10;i++){
		if(a[i]==1) {
			A|=1<<i;
			O|=1<<i;
		}
		if(a[i]==2) {
			A|=1<<i;
			X|=1<<i;
		}
		if(a[i]==3) {
			A|=1<<i;
		}
	}
	cout<<3<<endl;
	cout<<"& "<<A<<endl;
	cout<<"^ "<<X<<endl;
	cout<<"| "<<O<<endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b = 1023;
int c = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a |= x;
		if(s=="&") b &= x;
		if(s=="^") c ^= x;
	}
	puts("3");
	cout<<"| "<<a<<endl;
	cout<<"& "<<b<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b =1023;
int c = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") b|=x, a|=x;
		if(s=="&") a&=x, b&=x;
		if(s=="^") c^=x;
	}
	puts("3");
	cout<<"| "<<a<<endl;
	cout<<"& "<<b<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include<bits/stdc++.h>
#define x first
#define y second
#define NN 500100

using namespace std;
using INT=long long;
using pci=pair<char, int>;

const int N=1023;
pci p[NN];

char s[]={'&', '|', '^', };
int ans[20][2];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		char c;
		int x;
		scanf(" %c %d", &c, &x);
		p[i]=pci(c, x);
	}
	for(int i=0; i<10; i++) {
		for(int j=0; j<2; j++) {
			ans[i][j]=j;
			for(int k=1; k<=n; k++) {
				int tmp=p[k].y;
				int op=(tmp&(1<<i));
				if(op) op=1;
				if(p[k].x==s[0]) ans[i][j]=(ans[i][j]&op);
				if(p[k].x==s[1]) ans[i][j]=(ans[i][j]|op);
				if(p[k].x==s[2]) ans[i][j]^=op;
			}
		}
	}
	int x=0, y=0;
	for(int i=0; i<10; i++) {
		if(ans[i][0]==ans[i][1]) {
			x+=(1<<i);
			y+=(ans[i][0]^1)*(1<<i);
		}else {
			y+=(ans[i][0]^1)*(1<<i);
		}
	}
	cout<<2<<endl;
	cout<<s[1]<<" "<<x<<endl;
	cout<<s[2]<<" "<<y<<endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b =1023;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a|=x;
		if(s=="&") b&=x;
		if(s=="^") a^=x, b^=x;
	}
	puts("2");
	cout<<"| "<<a<<endl;
	cout<<"& "<<b<<endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

using INT = long long;

const int NN = 5e5+10;

char s[NN];
int a[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin >> n;
	for(int i=1; i<=n; i++) {
		scanf(" %c %d", s+i, a+i);
	}
	int sor = 0, sand = (1<<10)-1, sxor = 0;
	for(int i=0; i<10; i++) {
		int st1 = (1<<i);
		int st0 = 0;
		for(int j=1; j<=n; j++) {
			int x = 0;
			if((a[j]>>i)&1) x = (1<<i);
			if(s[j] == '|') st1 |= x, st0 |= x;
			if(s[j] == '&') st1 &= x, st0 &= x;
			if(s[j] == '^') st1 ^= x, st0 ^= x;
		}
		if(st1 and st0) {
			sor ^= (1<<i);
		}
		if(!st1 and st0) {
			sxor ^= (1<<i);
		}
		if(!st1 and !st0) {
			sand ^= (1<<i);
		}
	}
	cout << 3 << endl;
	cout << "|" << ' ' << sor << endl;
	cout << "&" << ' ' << sand << endl;
	cout << "^" << ' ' << sxor << endl;
}


#include <bits/stdc++.h>

using namespace std;

const int NN = 101010;

int a = 0;
int b = 0;
int c = 0;

string s[NN];
int x[NN];

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>s[i]>>x[i];
	}

	for(int j=0; j<10; j++) {
		int u=0, v=1<<j;
		for(int i=1; i<=n; i++) {
			if(s[i]=="|") u|=x[i], v|=x[i];
			if(s[i]=="&") u&=x[i], v&=x[i];
			if(s[i]=="^") u^=x[i], v^=x[i];
		}
		u&=(1<<j); v&=(1<<j);
		if(!u && !v) continue;
		if(!u && v) b|=1<<j;
		if(u && v) c|=1<<j;
		if(u && !v) b|=1<<j, c|=1<<j;
	}
	puts("2");
	cout<<"& "<<b<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a = 0;
int b =1023;
int c = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
#endif
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		string s; int x;
		cin>>s>>x;
		if(s=="|") a|=x;
		if(s=="&") b&=x;
		if(s=="^") a^=x, b^=x, c^=x;
	}
	puts("3");
	cout<<"| "<<(a^c)<<endl;
	cout<<"& "<<(b^c)<<endl;
	cout<<"^ "<<c<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	int num=1;
	for(int i=0;i<n;i++)
	{
		char c;
		int x;
		cin>>c>>x;
		if(c=='&')
		{
			num&=x;
		}
		else if(c=='|')
		{
			num|=x;
		}
		else
		{
			num^=x;
		}
	}
	int num2=1;
	for(int i=0;i<1023;i++)
	{
		for(int j=0;j<1023;j++)
		{
			num2=1;
			num2&=i;
			num2&=j;
			if(num2==num)
			{
				cout<<"2\n& "<<i<<endl;
				cout<<"& "<<j<<endl;
				return 0;
			}
		}
	}
	cout<<endl;
	return 0;
}


///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl
#define int long long
#define fe first
#define se second
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (x) << endl
#define PTT(x) cout << (#x) << " is " << (x) << endl
#define lets_go ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
const int N = 2000 + 10;
const int IM = 1e15 + 37;
const double PI = 3.1415926535897932384;
inline void PP(int n) { cout << n << " ";}
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " " ; cout << endl;}
void PVV(vii v) {for (int i = 0 ; i < v.size() ; i++) cout << v[i].first << " " << v[i].second << endl;}
void PA(int v[], int n, int x = 0) { for (int i = x ; i < n + x; i++)cout << v[i] << ' ' ; cout << endl;}
void IN(int a[], int n, int x = 0) {for (int i = x; i < n + x; i++)cin >> a[i];}
inline void op() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <=================================================================================================================================
// <=================================================================================================================================

signed  main() {
    op();
    lets_go

    bitset<10> a, b(1023);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char c;
        int x;
        cin >> c >> x;
        bitset<10> d(x);
        if (c == '|') {
            a = a | d;
            b = b | d;
        }
        else if (c == '&') {
            a = a & d;
            b = b & d;
        }
        else {
            a = a ^ d;
            b = b ^ d;
        }
    }
    int x = 0, y = 0, u = 1, z = 0;
    for (int i = 0; i < 10; i++) {
        if (a[i] == 0 && b[i] == 1)
            continue ;
        else if (a[i] && b[i])
            x = x | u;
        else if (a[i] == 0 && b[i] == 0)
            y = y | u;
        else if (a[i] == 1 && b[i] == 0) {
            z = z | u;
        }
        u = u * 2;
    }
    y = (1023 ^ y);
    int zz = (0 ^ z);
    cout << 4 << endl;
    cout << "^ " << z << endl;
    cout << "^ " << zz << endl;
    cout << "& " << y << endl;
    cout << "| " << x << endl;

    /**/
    return 0;
}