/*
codeforces878a 位运算化简
考虑每一位,对于0或者1,只有四种情况,
1.计算后恒为1
2.计算后恒为0
3.维持原数字
4.翻转
使用1023和0跑一遍计算,对于二进制十位中每一位可以判断出
属于哪种情况,然后构造相应的位运算即可
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define scfd(a) scanf("%d",a)
#define scflf(a) scanf("%lf",a)
#define scfs(a) scanf("%s",a)
#define ptfd(a) printf("%d\n",a)
#define ptfs(a) printf("%s\n",a)
#define showd(a,b) printf(a"=%d\n",b)
#define showlf(a,b) printf(a"=%lf\n",b)
#define shows(a,b) printf(a"=%s\n",b)
#define mmcp(a,b) memcpy(a,b,sizeof(b))
#define pb(a) push_back(a)
int n;
bitset<10>a,b,c,d,e;//| & ^ 11 00
int main(){
ios::sync_with_stdio(false);
cin>>n;
d.set(),e.reset();
fr(i,1,n){
char c;int t;
cin>>c>>t;
switch(c){
case '|':
d|=t,e|=t;
break;
case '&':
d&=t,e&=t;
break;
case '^':
d^=t,e^=t;
break;
}
}
a.reset(),b.set(),c.reset();
fr(i,0,9)
if(d[i]==1&&e[i]==1)a[i]=1;
else if(d[i]==0&&e[i]==0)b[i]=0;
else if(d[i]==1&&e[i]==0)c[i]=0;
else if(d[i]==0&&e[i]==1)c[i]=1;
cout<<"3"<<endl;
cout<<"| "<<a.to_ulong()<<endl;
cout<<"& "<<b.to_ulong()<<endl;
cout<<"^ "<<c.to_ulong()<<endl;
return 0;
}