#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f [30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
//    cout << "m=" << m << endl;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

//    cout << 322 << endl;
    cout << ans << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val2!=0) cout << "& " << val2 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f[30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
    ll h=0;
    m=10;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;\

        if (x1[i].fi=='&') h++;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
//        for (int i=0; i<aand.size(); i++) val2+=step[aand[i]-1];
        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
        for (int i=1; i<=10; i++) if (f[i]==0) val2+=step[i-1];

    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

    cout << ans << endl;
    if (val2!=0) cout << "& " << val2 << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val1!=0) cout << "| " << val1 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f [30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=0;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
//    cout << "m=" << m << endl;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='^') {
                     b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
                else if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

//    cout << 322 << endl;
    cout << ans << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val2!=0) cout << "& " << val2 << endl;

    return 0;
}


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f[30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
    ll h=0;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;\

        if (x1[i].fi=='&') h++;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
//        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
//        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
        for (int i=0; i<aand.size(); i++) val3+=step[aand[i]-1], val1+=step[aand[i]-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

    if (h) val2=step[m]-1;
    ans=0;
    if (val1!=0) ans++;
    if (val2!=0) ans++;
    if (val3!=0) ans++;

    cout << ans << endl;
    if (val2!=0) cout << "& " << val2 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val3!=0) cout << "^ " << val3 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f[30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
//    cout << "m=" << m << endl;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
//        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
//        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
        for (int i=0; i<aand.size(); i++) val3+=step[aand[i]-1], val1+=step[aand[i]-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

//    cout << 322 << endl;
    cout << ans << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val2!=0) cout << "& " << val2 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f[30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
//    cout << "m=" << m << endl;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
//        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
//        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
        for (int i=0; i<aand.size(); i++) val3+=step[aand[i]-1], val1+=step[aand[i]-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

//    cout << 322 << endl;
    cout << ans << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val2!=0) cout << "& " << val2 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f [30000];

int main()
{
 freopen("1.in", "r", stdin);
 freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
//    cout << "m=" << m << endl;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
//        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
//        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
        for (int i=0; i<aand.size(); i++) val3+=step[aand[i]-1], val1+=step[aand[i]-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

//    cout << 322 << endl;
    cout << ans << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val2!=0) cout << "& " << val2 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f [30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
    cout << "m=" << m << endl;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
        cout << endl;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
    }
    if (xoor.size()>0) {
        ans++;
        val3=0;
        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
    }

//    cout << 322 << endl;
    cout << ans << endl;
    if (val3!=0) cout << "^ " << val3 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val2!=0) cout << "& " << val2 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

vector<ll> oor,aand,xoor;
ll b[600000][30];
pair<char,ll> x1[600000];
ll step[30000];
ll f[30000];

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    ll n,val1=0, val2=0, val3=0, ans=0;
    ll z,a,m=0;

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;
    for (int i=1; i<=n; i++) {
        a=x1[i].se;
        z=1;
        while(a) a/=2, z++;
        m=max(z, m);
    }

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;
    ll h=0;

    for (int i=1; i<=m; i++) b[i][1]=1, b[i][0]=0;

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

//        for (int j=1; j<=m; j++) cout << "j=" << j << " 1=" << b[j][1] << " 2=" << b[j][0] << endl;
//        cout << endl;\

        if (x1[i].fi=='&') h++;

        z=1;
        a=x1[i].se;
        for (int j=1; j<=m; j++) {

            if ((a%2)==1) {
                if (x1[i].fi=='|') b[z][1]=1, b[z][0]=1;
                else if (x1[i].fi=='^') {
                    b[z][0]=1-b[z][0];
                    b[z][1]=1-b[z][1];
                }
            }
            else {
                if (x1[i].fi=='&') b[z][1]=0, b[z][0]=0;
            }
            a/=2;
            z++;
        }
    }

//    for (int i=1; i<=m; i++) cout << "i=" << i << " 1=" << b[i][1] << " 2=" << b[i][0] << endl;

    for (int i=1; i<=m; i++) {

        if (b[i][1]==1 and b[i][0]==1) oor.push_back(i);
        else if (b[i][1]==0 and b[i][0]==0) aand.push_back(i);
        else if (b[i][1]==0 and b[i][0]==1) xoor.push_back(i);

    }

//    for (int i=0; i<aand.size(); i++) cout << aand[i] << " ";
//    cout << endl;

    if (oor.size()>0) {
        ans++;
        val1=0;
        for (int i=0; i<oor.size(); i++) val1+=step[oor[i]-1];
    }
    if (aand.size()>0) {
        ans++;
        val2=0;
//        for (int i=0; i<aand.size(); i++) f[aand[i]]=1;
//        for (int i=1; i<=m; i++) if (f[i]==0) val2+=step[i-1];
        for (int i=0; i<aand.size(); i++) val3+=step[aand[i]-1], val1+=step[aand[i]-1];
    }
//    if (xoor.size()>0) {
//        ans++;
//        val3=0;
//        for (int i=0; i<xoor.size(); i++) val3+=step[xoor[i]-1];
//    }

    if (h) val2=step[m]-1;
    ans=0;
    if (val1!=0) ans++;
    if (val2!=0) ans++;
    if (val3!=0) ans++;

    cout << ans << endl;
    if (val2!=0) cout << "& " << val2 << endl;
    if (val1!=0) cout << "| " << val1 << endl;
    if (val3!=0) cout << "^ " << val3 << endl;

    return 0;
}
/*
5 2
2 1 4 3 5
*/


#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define m_p make_pair
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0)

typedef long long ll;
const int MAXINT=2147483640;
const ll MAXLL=9223372036854775800LL;
const ll MAXN=1000000;
const double pi=3.1415926535897932384626433832795;
using namespace std;

int main()
{
// freopen("1.in", "r", stdin);
// freopen("1.out", "w", stdout);

    fast_io;
    srand(time(0));

    cin >> n;
    for (int i=1; i<=n; i++) cin >> x1[i].fi >> x1[i].se;

    step[0]=1;
    for (int i=1; i<=40; i++) step[i]=step[i-1]*2;

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

        z=1;
        a=x1[i].se;
        while(a) {

            if (a%2==1) {
                if (x1[i].fi=='|') b[z]=1;
                else if (x1[i].fi=='^') {
                    if (b[z]==1) b[z]=2;
                    if (b[z]==2) b[z]=1;
                }
            }

        }

    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1023;
            int d=0;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
               dw=10;
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
              if(c==0)
                A[i]=1;
                else
             A[i]=h;
             c=c/2;
             if(A)
             int n=d%2;
               if(d==0)
                B[i]=0;
                  else
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<dw;i++)
              {    if(A[i]==0&&B[i]==0)
                    ;
                  else
                    num=num*2+1;
                   kq=1;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num*2+1;
               }
               else
               ;
           }
            cout<<'|'<<' '<<num<<endl;
           for(int i = 0;i<dw;i++)
           {
             num=0;
               if(A[i]==0&&B[i]==1)
               {
                   num=num*2+1;
               }
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1023;
            int d=0;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
               dw=10;
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
              if(c==0)
                A[i]=1;
                else
             A[i]=h;
             c=c/2;
             int n=d%2;
               if(d==0)
                B[i]=0;
                  else
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<dw;i++)
              {    if(A[i]==0&&B[i]==0)
                     num==num*2;
                  else
                    num=num*2+1;
                   kq=1;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num*2+1;
               }
               else
                num=num*2;
           }
            cout<<'|'<<' '<<num<<endl;
           for(int i = 0;i<dw;i++)
           {
             num=0;
               if(A[i]==0&&B[i]==1)
               {
                   num=num*2+1;
               }
               else
                num=num*2;
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[30];
           int B[30];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1024-1;
            int d=1024;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                        wes=0;
                      while(k)
                      {
                          k=k/2;
                            wes++;
                             //cout<<wes<<"W";
                      }
                       maxs=max(wes,maxs);
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
           int ands[40];
           memset(ands,0,sizeof(ands));
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
             A[i]=h;
             c=c/2;
             int n=d%2;
             B[i]=n;
              d=d/2;
         }
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<maxs;i++)
              {
                  num=num*2+1;
                   kq=1;
              }
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==0)
               {
                        sx=1;
               }
               else
                num=num*2+1;
           }
           for(int i = 0;i<dw;i++)
           {
               int num=0;
               if(A[i]=='0'&&B[i]=='1')
               {
                   num=num*2+1;
                    hs=1;
               }
           }
                num=0;
              cout<<kq+sx+hs<<endl;
              for(int i=0;i<maxs;i++)
              {
                  num=num*2+1;
                   kq=1;
              }
                  if(kq)
                 cout<<'|'<<' '<<num<<endl;
                  num=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==0)
               {
                        sx=1;
               }
               else
                num=num*2+1;
           }
             if(sx)
            cout<<'&'<<' '<<num<<endl;
               num=0;
           for(int i = 0;i<dw;i++)
           {
               num=0;
               if(A[i]=='0'&&B[i]=='1')
               {
                   num=num*2+1;
                    hs=1;
               }
           }
             if(hs)
            cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1023;
            int d=0;
               char a;
                  cin>>n;
             int kz;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>kz;
                     fwq=max(fwq,kz);
                  if(a=='|')
                  {
                      c=c|kz;
                      d=d|kz;
                  }
                  else if(a=='&')
                  {
                      c=c&kz;
                       d=d&kz;
                  }
                  else if(a=='^')
                  {
                      c=c^kz;
                      d=d^kz;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
               dw=10;
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
              if(c==0)
                A[i]=1;
                else
             A[i]=h;
             c=c/2;
             int n=d%2;
               if(d==0)
                B[i]=0;
                  else
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                   int k=1;
                  for(int i=0;i<dw;i++)
              {
                  if(A[i]==0&&B[i]==0)
                     ;
                  else
                     num=num+k;
                      k=k*2;
                   kq=1;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
                     k=1;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num+k;
               }
               else
               ;
               k=k*2;
           }
            cout<<'|'<<' '<<num<<endl;
              num=0;
               k=1;
           for(int i = 0;i<dw;i++)
           {
               if(A[i]==0&&B[i]==1)
               {
                 num=num+k;
               }
               else
                ;
                k=k*2;
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1024-1;
            int d=1024;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
           int ands[40];
           memset(ands,0,sizeof(ands));
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
             A[i]=h;
             c=c/2;
             int n=d%2;
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<dw;i++)
              {    if(A[i]==0&&B[i]==0)
                    ;
                  else
                    num=num*2+1;
                   kq=1;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num*2+1;
               }
               else
               ;
           }
            cout<<'|'<<' '<<num<<endl;
           for(int i = 0;i<dw;i++)
           {
             num=0;
               if(A[i]=='0'&&B[i]=='1')
               {
                   num=num*2+1;
               }
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1023;
            int d=0;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
               dw=10;
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
              if(c==0)
                A[i]=1;
                else
             A[i]=h;
             c=c/2;
             int n=d%2;
               if(d==0)
                B[i]=0;
                  else
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<dw;i++)
              {    if(A[i]==0&&B[i]==0)
                     num=num*2;
                  else
                    num=num*2+1;
                   kq=1;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num*2+1;
               }
               else
                num=num*2;
           }
            cout<<'|'<<' '<<num<<endl;
           for(int i = 0;i<dw;i++)
           {
             num=0;
               if(A[i]==0&&B[i]==1)
               {
                   num=num*2+1;
               }
               else
                num=num*2;
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1023;
            int d=0;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=32;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
             A[i]=h;
             c=c/2;
             int n=d%2;
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<dw;i++)
              {    if(A[i]==0&&B[i]==0)
                    ;
                  else
                    num=num*2+1;
                   kq=1;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num*2+1;
               }
               else
               ;
           }
            cout<<'|'<<' '<<num<<endl;
           for(int i = 0;i<dw;i++)
           {
             num=0;
               if(A[i]==0&&B[i]==1)
               {
                   num=num*2+1;
               }
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[30];
           int B[30];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1024-1;
            int d=1024;
               char a;
                  cin>>n;
             int k;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>k;
                     fwq=max(fwq,k);
                  if(a=='|')
                  {
                      c=c|k;
                      d=d|k;
                        wes=0;
                      while(k)
                      {
                          k=k/2;
                      }
                  }
                  else if(a=='&')
                  {
                      c=c&k;
                       d=d&k;
                  }
                  else if(a=='^')
                  {
                      c=c^k;
                      d=d^k;
                  }
        }
              int dw=0;
            while(fwq)
            {
                fwq=fwq/2;
                 dw++;
            }
           int ands[40];
           memset(ands,0,sizeof(ands));
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
             A[i]=h;
             c=c/2;
             int n=d%2;
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                  for(int i=0;i<dw;i++)
              {    if(A[i]==0&&B[i]==0)
                    ;
                  else
                    num=num*2+1;
                   kq=1;
              }
                     cout<<'&'<<num<<endl;
                       num=0;
                    int  sx=0;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num*2+1;
               }
               else
               ;
           }
            cout<<'|'<<' '<<num<<endl;
           for(int i = 0;i<dw;i++)
           {
             num=0;
               if(A[i]=='0'&&B[i]=='1')
               {
                   num=num*2+1;
               }
           }
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{      int n;
           int A[40];
           int B[40];
            memset(A,0,sizeof(A));
            memset(B,0,sizeof(B));
            int c=1023;
            int d=0;
               char a;
                  cin>>n;
             int kz;
              int ds=0;
                int wes=0;
                  int maxs=0;
                    int fwq=0;
        for(int i=0;i<n;i++)
        {
                cin>>a>>kz;
                     fwq=max(fwq,kz);
                  if(a=='|')
                  {
                      c=c|kz;
                      d=d|kz;
                  }
                  else if(a=='&')
                  {
                      c=c&kz;
                       d=d&kz;
                  }
                  else if(a=='^')
                  {
                      c=c^kz;
                      d=d^kz;
                  }
        }
              int dw=0;
               dw=10;
         for(int i=0;i<dw;i++)
         {
             int h=c%2;
             A[i]=h;
             c=c/2;
             int n=d%2;
             B[i]=n;
              d=d/2;
         }
                  cout<<3<<endl;
               int kq=0;
              int num=0;
                 int hs=0;
                   int k=1;
                  for(int i=0;i<dw;i++)
              {
                  if(A[i]==0&&B[i]==0)
                     ;//num=num+k;
                  else
                     num=num+k;
                      k=k*2;
              }
                     cout<<'&'<<' '<<num<<endl;
                       num=0;
                    int  sx=0;
                     k=1;
           for(int i=0;i<dw;i++)
           {
               if(A[i]==B[i]&&A[i]==1)
               {
                       num=num+k;
               }
               else
               ;
               k=k*2;
           }
            cout<<'|'<<' '<<num<<endl;
              num=0;
               k=1;
           for(int i = 0;i<dw;i++)
           {
               if(A[i]==0&&B[i]==1)
               {
                 num=num+k;
               }
               else
                ;
                k=k*2;
           }
                   int kw=0;
                          kw=kw&1;
                          kw=kw&3;
                          kw=kw&5;
                  cout<<'^'<<' '<<num<<endl;
    return 0;
}


#include<cstdio>
#include<iostream>
int ans1,ans2=1023;
int n,x;
char c;
int main(){
	scanf("%d",&n);
	while(n--){
		while(c=getchar(),c=='\n'||c==' ');
		scanf("%d",&x);
		if(c=='&')ans1&=x,ans2&=x;
		if(c=='|')ans1|=x,ans2|=x;
		if(c=='^')ans1^=x,ans2^=x;
	}
	printf("3\n& %d\n^ %d\n| %d\n",1023&ans1|ans2,ans1&(1023^ans2),ans1&ans2);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int ad = 1023,xr,r;

int n;

int main(){
	cin>>n;
	char c;
	int a;
	for( int i=0;i<n;i++ ){
		cin>>c>>a;
		if( c == '&' ) ad &= a;
		else if( c == '|' ) r |= a;
		else xr ^= a;
	}

        cout<<3;
		cout<<"\n| "<<r;
		cout<<"\n& "<<ad;
		cout<<"\n^ "<<xr;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int ad = 1023,xr,r;

int n;
bool f[3];

int main(){
	cin>>n;
	int ct = 0;
	for( int i = 0 ; i < n ; i++ ){
		char c;
		int a;
		cin>>c>>a;
		if( c == '&' ){
			ad &= a;
			f[0] = true;
		}
		else if( c == '|' ){
			r |= a;
			f[1] = true;
		}
		else {
			xr ^= a;
			f[2] = true;
		}
	}

	for( int i=0;i<3;i++ )
		if(f[i])
			ct++;

    cout<<ct<<endl;
    if( f[1] )
		cout<<"| "<<r<<endl;
	if( f[0] )
		cout<<"& "<<ad<<endl;
	if( f[2] )
		cout<<"^ "<<xr;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int ad = 1023,xr,r;

int n;
bool f[3];

int main(){
	cin>>n;
	char c;
	int a;
	int ct=0;
	for( int i=0;i<n;i++ ){
		cin>>c>>a;
		if( c == '&' ){
			 ad &= a;
			 	f[0] = true;
			 	ct++;
			 	}
		else if( c == '|' ){
			r |= a;
			ct++;
			f[1] = true;
		}
		else {
			xr ^= a;
			f[2] =true;
			ct++;
		}
	}

        cout<<ct;
        if( f[1] )
		cout<<"\n| "<<r;
		if(f[0])
		cout<<"\n& "<<ad;
		if(f[2])
		cout<<"\n^ "<<xr;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int ad = 1023,xr,r;

int n;

int main(){
	cin>>n;
		for( int i = 0 ; i < n ; i++ ){
		char c;
		int a;
		cin>>c>>a;
		if( c == '&' ){
			ad &= a;

		}
		else if( c == '|' ){
			ad |= a;
		}
		else {
			ad ^= a;
		}
	}

    cout<<1<<endl;
    cout<<"& "<<ad<<endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int ad = 1023,xr,r;

int n;
bool f[3];

int main(){
	cin>>n;
	char c;
	int a;
	int ct=0;
	for( int i=0;i<n;i++ ){
		cin>>c>>a;
		if( c == '&' ){
			 ad &= a;
			 	f[0] = true;
			 	}
		else if( c == '|' ){
			r |= a;
			f[1] = true;
		}
		else {
			xr ^= a;
			f[2] =true;
		}
	}

	for( int i=0;i<3;i++ )
		if(f[i])
			ct++;

        cout<<ct;
        if( f[1] )
		cout<<"\n| "<<r;
		if(f[0])
		cout<<"\n& "<<ad;
		if(f[2])
		cout<<"\n^ "<<xr;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;
bool _or[MAX];
bool _and[MAX];

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    for(int i=0; i<10; i++)
    {
        _or[i] = 1;
        _and[i] = 1;
    }

    for(int j=0; j < (1 << 10); j++)
    {
        int k = j;
        for(int i=0; i<n; i++)
            if(op[i] == '|') k |= val[i];
            else if(op[i] == '^') k ^= val[i];
            else k &= val[i];

        for(int i=0; i<10; i++)
            if(!(k & (1 << i)))
                _or[i] = 0;

        for(int i=0; i<10; i++)
            if((k & (1 << i)))
                _and[i] = 0;
    }

    int ans1 = 0;
    int ans2 = 1023;

    for(int i=0; i<10; i++)
    {
        if(_or[i]) ans1 |= (1 << i);
        if(_and[i]) ans2 ^= (1 << i);
    }

    printf("%d\n",2);
    printf("| %d\n",ans1);
    printf("& %d\n",ans2);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    int a = 0;
    int b = (1 << 10) - 1;

    for(int i=0; i<n; i++)
    {
        if(op[i] == '|') {a |= val[i]; b |= val[i];}
            else if(op[i] == '^') {a ^= val[i]; b ^= val[i];}
            else {a &= val[i]; b &= val[i];}
    }

    int ans1 = 0;
    int ans2 = 1023;
    int ans3 = 0;

    for(int i=0; i<10; i++)
    {
        if((a & (1 << i)) && !(b & (1 << i))) ans3 |= (1 << i);
        if((a & (1 << i)) && (b & (1 << i))) ans1 |= (1 << i);
        if(!(a & (1 << i)) && !(b & (1 << i))) ans3 ^= (1 << i);
    }

    printf("%d\n",3);
    printf("^ %d\n",ans3);
    printf("| %d\n",ans1);
    printf("& %d\n",ans2);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%c %d",&op[i],&val[i]);

    int res = val[0];
    for(int i=1; i<n; i++)
        if(op[i] == '|') res |= val[i];
        else if(op[i] == '^') res ^= val[i];
        else res &= val[i];

    printf("2\n");
    printf("| %d\n",res);
    printf("| %d\n",0);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;
bool _or[MAX];
bool _and[MAX];
bool _xor[MAX];

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    for(int i=0; i<10; i++)
    {
        _or[i] = 1;
        _and[i] = 1;
        _xor[i] = 1;
    }

    for(int j=0; j < (1 << 10); j++)
    {
        int k = j;
        for(int i=0; i<n; i++)
            if(op[i] == '|') k |= val[i];
            else if(op[i] == '^') k ^= val[i];
            else k &= val[i];

        for(int i=0; i<10; i++)
        {
            if(!(k & (1 << i)))
                _or[i] = 0;

            if((k & (1 << i)))
                _and[i] = 0;

            if(!((k ^ j) & (1 << i)))
                _xor[i] = 0;
        }
    }

    int ans1 = 0;
    int ans2 = 1023;
    int ans3 = 0;

    for(int i=0; i<10; i++)
    {
        if(_or[i]) ans1 |= (1 << i);
        if(_and[i]) ans2 ^= (1 << i);
        if(_xor[i]) ans3 |= (1 << i);
    }

    printf("%d\n",3);
    printf("^ %d\n",ans3);
    printf("| %d\n",ans1);
    printf("& %d\n",ans2);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    int a = 0;
    int b = (1 << 10) - 1;

    for(int i=0; i<n; i++)
    {
        if(op[i] == '|') {a |= val[i]; b |= val[i];}
            else if(op[i] == '^') {a ^= val[i]; b ^= val[i];}
            else {a &= val[i]; b &= val[i];}
    }

    int ans1 = 0;
    int ans2 = 1023;
    int ans3 = 0;

    for(int i=0; i<10; i++)
    {
        if((a & (1 << i)) && !(b & (1 << i))) ans3 |= (1 << i);
        if((a & (1 << i)) && (b & (1 << i))) ans1 |= (1 << i);
        if(!(a & (1 << i)) && !(b & (1 << i))) ans2 ^= (1 << i);
    }

    printf("%d\n",3);
    printf("^ %d\n",ans3);
    printf("| %d\n",ans1);
    printf("& %d\n",ans2);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    int res = val[0];
    for(int i=1; i<n; i++)
        if(op[i] == '|') res |= val[i];
        else if(op[i] == '^') res ^= val[i];
        else res &= val[i];

    printf("4\n");
    printf("| %d\n",res);
    printf("| %d\n",0);
    printf("^ %d\n",0);
    printf("& %d\n",1);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;
bool _or[MAX];
bool _and[MAX];
bool _xor[MAX];

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    for(int i=0; i<10; i++)
    {
        _or[i] = 1;
        _and[i] = 1;
        _xor[i] = 1;
    }

    for(int j=0; j < (1 << 10); j++)
    {
        int k = j;
        for(int i=0; i<n; i++)
            if(op[i] == '|') k |= val[i];
            else if(op[i] == '^') k ^= val[i];
            else k &= val[i];

        for(int i=0; i<10; i++)
        {
            if(!(k & (1 << i)))
                _or[i] = 0;

            if((k & (1 << i)))
                _and[i] = 0;

            if(!((k ^ j) & (1 << i)))
                _xor[i] = 0;
        }
    }

    int ans1 = 0;
    int ans2 = 1023;
    int ans3 = 0;

    for(int i=0; i<10; i++)
    {
        if(_or[i]) ans1 |= (1 << i);
        if(_and[i]) ans2 ^= (1 << i);
        if(_and[i]) ans3 |= (1 << i);
    }

    printf("%d\n",3);
    printf("^ %d\n",ans3);
    printf("| %d\n",ans1);
    printf("& %d\n",ans2);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;
bool _or[MAX];
bool _and[MAX];
bool _xor[MAX];

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf(" %c%d",&op[i],&val[i]);

    for(int i=0; i<10; i++)
    {
        _or[i] = 1;
        _and[i] = 1;
        _xor[i] = 1;
    }

    for(int j=0; j < (1 << 10); j++)
    {
        int k = j;
        for(int i=0; i<n; i++)
            if(op[i] == '|') k |= val[i];
            else if(op[i] == '^') k ^= val[i];
            else k &= val[i];

        for(int i=0; i<10; i++)
        {
            if(!(k & (1 << i)))
                _or[i] = 0;

            if((k & (1 << i)))
                _and[i] = 0;

            if(!((k ^ j) & (1 << i)))
                _xor[i] = 0;
        }
    }

    int ans1 = 0;
    int ans2 = 1023;
    int ans3 = 0;

    for(int i=0; i<10; i++)
    {
        if(_or[i]) ans1 |= (1 << i);
        if(_and[i]) ans2 ^= (1 << i);
        if(_and[i]) ans3 |= (1 << i);
    }

    printf("%d\n",3);
    printf("| %d\n",ans1);
    printf("& %d\n",ans2);
    printf("^ %d\n",ans3);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%c %d",&op[i],&val[i]);

    int res = val[0];
    for(int i=1; i<n; i++)
        if(op[i] == '|') res |= val[i];
        else if(op[i] == '^') res ^= val[i];
        else res &= val[i];

    printf("2\n");
    printf("| %d",res);
    printf("| %d",0);

}


#include <bits/stdc++.h>
using namespace std;
#define sz size()
#define x first
#define y second
#define mp make_pair
#define mpp(a,b,c) make_pair(make_pair(a,b),c)
#define pb push_back
#define all(v) v.begin(),v.end()
#define EPS 1e-9
#define MOD 1000000007
#define MAX 500005
typedef pair<int,int> pii;
typedef long long ll;

char op[MAX];
int val[MAX];
int n;

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%c %d",&op[i],&val[i]);

    int res = val[0];
    for(int i=1; i<n; i++)
        if(op[i] == '|') res |= val[i];
        else if(op[i] == '^') res ^= val[i];
        else res &= val[i];

    printf("4\n");
    printf("| %d\n",res);
    printf("| %d\n",0);
    printf("^ %d\n",0);
    printf("& %d\n",1);

}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
#include<vector>
using namespace std;
map<char, int>mp;
vector<int>q[4];
struct node{
    char c;
    int now;
};
vector<node>ans;
int main(){
    mp['|'] = 1;
    mp['&'] = 2;
    mp['^'] = 3;
    int n;
    scanf("%d", &n);
    while(n--){
        char s[2];
        int now;
        scanf("%s%d", s, &now);
        q[mp[s[0]]].push_back(now);
    }

    int len = q[1].size();
    if(len != 0){
        int now = q[1][0];
        for(int i = 1; i < len; i ++)
            now |= q[1][i];

        if(now != 0)    ans.push_back(node{'|', now});
    }
    len = q[2].size();
    if(len != 0){
        int now = q[2][0];
        for(int i =1 ;i < len; i ++)
            now &= q[2][i];
        ans.push_back(node{'&', now});
    }
    len = q[3].size();
    if(len != 0){
        int now = q[3][0];
        for(int i = 1; i < len; i ++)
            now ^= q[3][i];
        if(now != 0)    ans.push_back(node{'^', now});
    }

    printf("%d\n", (int)ans.size());
    for(int i = 0; i < ans.size(); i ++)
        printf("%c %d\n", ans[i].c, ans[i].now);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<map>
#include<vector>
using namespace std;
map<char, int>mp;
vector<int>q[4];
struct node{
    char c;
    int now;
};
vector<node>ans;
int main(){
    mp['|'] = 1;
    mp['&'] = 2;
    mp['^'] = 3;
    int n;
    scanf("%d", &n);
    while(n--){
        char s[2];
        int now;
        scanf("%s%d", s, &now);
        q[mp[s[0]]].push_back(now);
    }

    int len = q[1].size();
    if(len != 0){
        int now = q[1][0];
        for(int i = 1; i < len; i ++)
            now |= q[1][i];

        ans.push_back(node{'|', now});
    }
    len = q[2].size();
    if(len != 0){
        int now = q[2][0];
        for(int i =1 ;i < len; i ++)
            now &= q[2][i];
        ans.push_back(node{'&', now});
    }
    len = q[3].size();
    if(len != 0){
        int now = q[3][0];
        for(int i = 1; i < len; i ++)
            now ^= q[3][i];
        ans.push_back(node{'^', now});
    }

    printf("%d\n", (int)ans.size());
    for(int i = 0; i < ans.size(); i ++)
        printf("%c %d\n", ans[i].c, ans[i].now);
    return 0;
}


//CF 443 Problem C
//10.27  16:16
#include "iostream"
#include "cstdio"
#include "vector"
#include "bitset"
#include "map"
using namespace std;
char c[10] = " ^|&";
int main(){
    int n;

    scanf("%d", &n);
    int a = 0, b = 1023;
    for(int i = 1; i <= n; i ++){
        char s[2];
        int now;
        scanf("%s%d", s, &now);
        if(s[0] == '^') {
            a ^= now;
            b ^= now;
        } else if(s[0] == '&'){
            a &= now;
            b &= now;
        } else {
            a |= now;
            b |= now;
        }
    }

    bitset<12>A(a), B(b);
    int ans[4][12] = {0};
    for(int i = 0; i < 10;i ++)
        ans[3][i] = 1;
    for(int i = 0; i < 10; i ++){
        if(A[i] == 1 && B[i] == 1)  ans[1][i] = 1;
        else if(A[i] == 1 && B[i] == 0) ans[1][i] = 1;
        else if(A[i] == 0 && B[i] == 0) ans[3][i] = 0;
    }

    printf("3\n");
    for(int i = 1; i <= 3; i ++){
        int now = 0;
        for(int j = 0; j < 10; j ++)    now += ans[i][j] * (1<<j);
        printf("%c %d\n", c[i], now);
    }
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int ans[15];
void judge(int k,char ch){
	int index=9;
	while(k){
		if(ans[index]==-1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='|'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==0){
			if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=0;
			}
		}
		index--;
		k>>=1;
	}
}
int main()
{
	int n;
	while(~scanf("%d%*c",&n)){
		memset(ans,-1,sizeof(ans));
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			judge(k,ch);

		}
		int _or=0;
		int _xor=0;
		for(int i=0;i<10;++i){
			_or<<=1;
			_xor<<=1;
			if(ans[i]==0){
				_or+=1;
				_xor+=1;
			}
			else if(ans[i]==1){
				_or+=1;
			}
		}
		printf("2\n| %d\n^ %d\n",_or,_xor);
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int ans[15];
void judge(int k,char ch){
	int index=9;
	while(k){
		if(ans[index]==-1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='|'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==0){
			if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=0;
			}
		}
		index--;
		k>>=1;
	}
	if(ch=='&'){
		for(index;index>=0;--index){
			ans[index]=0;
		}
	}
}
int main()
{
	int n;
	while(~scanf("%d%*c",&n)){
		memset(ans,-1,sizeof(ans));
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			judge(k,ch);

		}
		int _or=0;
		int _xor=0;
		for(int i=0;i<10;++i){
			_or<<=1;
			_xor<<=1;
			if(ans[i]==0){
				_or+=1;
				_xor+=1;
			}
			else if(ans[i]==1){
				_or+=1;
			}
		}
		printf("2\n| %d\n^ %d\n",_or,_xor);
	}
	/*int n;
	while(~scanf("%d",&n)){
		printf("%d\n",(n|1022)^1022);
		printf("%d\n",n&1);
	}*/
	//system("pause");
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int ans[15];
void judge(int k,char ch){
	int index=9;
	while(k){
		if(ans[index]==-1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=-2;
			}
		}
		else if(ans[index]==-2){
			if(ch=='^'){
				if(k&1) ans[index]=-1;
			}
		}
		else if(ans[index]==0){
			if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=0;
			}
		}
		index--;
		k>>=1;
	}
	if(ch=='&'){
		for(index;index>=0;--index){
			ans[index]=0;
		}
	}
}
int main()
{
	int n;
	while(~scanf("%d%*c",&n)){
		memset(ans,-1,sizeof(ans));
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			judge(k,ch);

		}
		int _or=0;
		int _xor=0;
		for(int i=0;i<10;++i){
			_or<<=1;
			_xor<<=1;
			if(ans[i]==-2){
				_xor+=1;
			}
			if(ans[i]==0){
				_or+=1;
				_xor+=1;
			}
			else if(ans[i]==1){
				_or+=1;
			}
		}
		printf("2\n| %d\n^ %d\n",_or,_xor);
	}
	/*int n;
	while(~scanf("%d",&n)){
		printf("%d\n",(n|1022)^1022);
		printf("%d\n",n&1);
	}*/
	//system("pause");
	return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int ans[15];
void judge(int k,char ch){
	int index=9;
	while(k){
		if(ans[index]==-1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='|'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==0){
			if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=0;
			}
		}
		index--;
		k>>=1;
	}
}
int main()
{
	int n;
	while(~scanf("%d%*c",&n)){
		memset(ans,-1,sizeof(ans));
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			judge(k,ch);

		}
		int or=0;
		int xor=0;
		for(int i=0;i<10;++i){
			or<<=1;
			xor<<=1;
			if(ans[i]==0){
				or+=1;
				xor+=1;
			}
			else if(ans[i]==1){
				or+=1;
			}
		}
		printf("2\n| %d\n^ %d\n",or,xor);
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int ans[15];
void judge(int k,char ch){
	int index=9;
	while(k){
		if(ans[index]==-1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=-2;
			}
		}
		else if(ans[index]==-2){
			if(ch=='^'){
				if(k&1) ans[index]=-1;
			}
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
		}
		else if(ans[index]==0){
			if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=0;
			}
		}
		index--;
		k>>=1;
	}
	if(ch=='&'){
		for(index;index>=0;--index){
			ans[index]=0;
		}
	}
}
int main()
{
	int n;
	while(~scanf("%d%*c",&n)){
		memset(ans,-1,sizeof(ans));
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			judge(k,ch);

		}
		int _or=0;
		int _xor=0;
		for(int i=0;i<10;++i){
			_or<<=1;
			_xor<<=1;
			if(ans[i]==-2){
				_xor+=1;
			}
			if(ans[i]==0){
				_or+=1;
				_xor+=1;
			}
			else if(ans[i]==1){
				_or+=1;
			}
		}
		printf("2\n| %d\n^ %d\n",_or,_xor);
	}
	/*int n;
	while(~scanf("%d",&n)){
		printf("%d\n",(n|1022)^1022);
		printf("%d\n",n&1);
	}*/
	//system("pause");
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
int ans[15];
void judge(int k,char ch){
	int index=9;
	while(k){
		if(ans[index]==-1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='|'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==0){
			if(ch=='|'){
				if(k&1) ans[index]=1;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=1;
			}
		}
		else if(ans[index]==1){
			if(ch=='&'){
				if(!(k&1)) ans[index]=0;
			}
			else if(ch=='^'){
				if(k&1) ans[index]=0;
			}
		}
		index--;
		k>>=1;
	}
}
int main()
{
	int n;
	while(~scanf("%d%*c",&n)){
		memset(ans,-1,sizeof(ans));
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			judge(k,ch);

		}
		int _or=0;
		int _xor=0;
		for(int i=0;i<10;++i){
			_or<<=1;
			_xor<<=1;
			if(ans[i]==0){
				_or+=1;
				_xor+=1;
			}
			else if(ans[i]==1){
				_or+=1;
			}
		}
		printf("2\n| %d\n^ %d\n",_or,_xor);
	}
	system("pause");
	return 0;
}


#include<stdio.h>
#include<map>
using namespace std;
int main(){
	int n;
	while(~scanf("%d%*c",&n)){
		map<char,int> mp;
		map<char,int>::iterator it;
		char order[4];
		while(n--){
			char ch;
			int k;
			scanf("%c%d%*c",&ch,&k);
			it=mp.find(ch);
			if(it==mp.end()){
				if(k==0) continue;
				order[mp.size()]=ch;
				mp.insert(pair<char,int>(ch,k));
			}
			else{
				if(it->first == '|'){
					it->second |= k;
				}
				else if(it->first == '&'){
					it->second &= k;
				}
				else it->second ^= k;
				if(it->second == 0){
					bool flag=false;
					for(int i=0;i<mp.size();++i){
						if(order[i]==it->first){
							flag=true;
						}
						if(flag){
							order[i]=order[i+1];
						}
					}
					mp.erase(it);
				}
			}
		}
		printf("%d\n",mp.size());
		for(int i=0;i<mp.size();++i){
			printf("%c %d\n",order[i],mp.find(order[i])->second);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<D> CPX;
typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,LL> PDLL;
typedef pair<D,I> PDI;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDLL> VPDLL;
typedef vector<PDI> VPDI;
typedef set<I> SI;
typedef set<LL> SLL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<CPX> SCPX;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
typedef set<PDLL> SPDLL;
typedef set<PDI> SPDI;

#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,N) sort((x),(x)+(N))
#define lsrt(x,L) sort(all(x),(L))
#define lsrtn(x,N,L) sort((x),(x)+(N),(L))
#define sz(v) ((int)(v).size())
#define ifor(i,st,ed) for(int i=(st);i<=(ed);++i)
#define jfor(i,st,ed,step) for(int i=(st);i<=(ed);i+=step)
#define dfor(i,st,ed) for(int i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define cout(x) cout<<fixed<<setprecision(x)
#define pln1(a) cout<<(a)<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<(a)<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl

I arr[11];
bool rev[11];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    I n;cin>>n;
    ifor(i,1,n)
    {
        char op;I a;cin>>op>>a;
        I ps = 0;
        ifor(i,0,9)
        {
            I nxt = a&1;a>>=1;
            if(op=='|')
            {
                if(nxt==1){arr[ps] = 1;rev[ps] = 0;}
            }
            if(op=='&')
            {
                if(nxt==0){arr[ps] = 2;rev[ps] = 0;}
            }
            if(op=='^')
            {
                if(nxt==1)
                {
                    rev[ps]^=1;
                }
            }
            ++ps;
        }
    }
    I an = 0, xo = 0, o = 0;
    dfor(i,9,0)
    {
        an<<=1;xo<<=1;o<<=1;
        if(arr[i]!=2)an|=1;
        if(rev[i])xo|=1;
        if(arr[i]==1)o|=1;
    }
    I cnt = 0;
    cout << 3 << endl;
    cout << "& " << an << endl;
    cout << "| " << o << endl;
    cout << "^ " << xo << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<D> CPX;
typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,LL> PDLL;
typedef pair<D,I> PDI;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDLL> VPDLL;
typedef vector<PDI> VPDI;
typedef set<I> SI;
typedef set<LL> SLL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<CPX> SCPX;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
typedef set<PDLL> SPDLL;
typedef set<PDI> SPDI;

#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,N) sort((x),(x)+(N))
#define lsrt(x,L) sort(all(x),(L))
#define lsrtn(x,N,L) sort((x),(x)+(N),(L))
#define sz(v) ((int)(v).size())
#define ifor(i,st,ed) for(int i=(st);i<=(ed);++i)
#define jfor(i,st,ed,step) for(int i=(st);i<=(ed);i+=step)
#define dfor(i,st,ed) for(int i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define cout(x) cout<<fixed<<setprecision(x)
#define pln1(a) cout<<(a)<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<(a)<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    I n;cin>>n;
    VI xorl, orl , andl;
    ifor(i,1,n)
    {
        char s;I a;
        cin>>s>>a;
        if(s=='|')orl.eb(a);
        if(s=='^')xorl.eb(a);
        if(s=='&')andl.eb(a);
    }
    I x=0,o=0,an=1023;
    ifor(i,0,sz(xorl)-1)x^=xorl[i];
    ifor(i,0,sz(orl)-1)o|=orl[i];
    ifor(i,0,sz(andl)-1)an&=andl[i];
    I cnt = 0;
    if(x!=0)++cnt;
    if(o!=0)++cnt;
    if(an!=1023)++cnt;
    cout << cnt << endl;
    if(an!=1023)cout << "& " << an << endl;
    if(o!=0)cout << "| " << o << endl;
    if(x!=0)cout << "^ " << x << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<D> CPX;
typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,LL> PDLL;
typedef pair<D,I> PDI;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDLL> VPDLL;
typedef vector<PDI> VPDI;
typedef set<I> SI;
typedef set<LL> SLL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<CPX> SCPX;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
typedef set<PDLL> SPDLL;
typedef set<PDI> SPDI;

#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,N) sort((x),(x)+(N))
#define lsrt(x,L) sort(all(x),(L))
#define lsrtn(x,N,L) sort((x),(x)+(N),(L))
#define sz(v) ((int)(v).size())
#define ifor(i,st,ed) for(int i=(st);i<=(ed);++i)
#define jfor(i,st,ed,step) for(int i=(st);i<=(ed);i+=step)
#define dfor(i,st,ed) for(int i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define cout(x) cout<<fixed<<setprecision(x)
#define pln1(a) cout<<(a)<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<(a)<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    I n;cin>>n;
    VI xorl, orl , andl;
    ifor(i,1,n)
    {
        char s;I a;
        cin>>s>>a;
        if(s=='|')orl.eb(a);
        if(s=='^')xorl.eb(a);
        if(s=='&')andl.eb(a);
    }
    I x=0,o=0,an=1023;
    ifor(i,0,sz(xorl)-1)x^=xorl[i];
    ifor(i,0,sz(orl)-1)o|=orl[i];
    ifor(i,0,sz(andl)-1)an&=andl[i];
    I cnt = 0;
    if(x!=0)++cnt;
    if(o!=0)++cnt;
    if(an!=1023)++cnt;
    cout << cnt << endl;
    if(x!=0)cout << '^' << x << endl;
    if(o!=0)cout << '|' << o << endl;
    if(an!=1023)cout << '&' << an << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef double D;
typedef long long int LL;
typedef long double LD;
typedef complex<D> CPX;
typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<D,LL> PDLL;
typedef pair<D,I> PDI;
typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<CPX> VCPX;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDLL> VPDLL;
typedef vector<PDI> VPDI;
typedef set<I> SI;
typedef set<LL> SLL;
typedef set<D> SD;
typedef set<LD> SLD;
typedef set<CPX> SCPX;
typedef set<PII> SPII;
typedef set<PLL> SPLL;
typedef set<PDLL> SPDLL;
typedef set<PDI> SPDI;

#define endl '\n'
#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ins insert
#define ers erase
#define lb lower_bound
#define ub upper_bound
#define fd find
#define all(x) (x).begin(),(x).end()
#define srt(x) sort(all(x))
#define srtn(x,N) sort((x),(x)+(N))
#define lsrt(x,L) sort(all(x),(L))
#define lsrtn(x,N,L) sort((x),(x)+(N),(L))
#define sz(v) ((int)(v).size())
#define ifor(i,st,ed) for(int i=(st);i<=(ed);++i)
#define jfor(i,st,ed,step) for(int i=(st);i<=(ed);i+=step)
#define dfor(i,st,ed) for(int i=(st);i>=(ed);--i)
#define efor(it,x) for(auto it:(x))
#define cout(x) cout<<fixed<<setprecision(x)
#define pln1(a) cout<<(a)<<endl
#define pln2(a,b) cout<<(a)<<' '<<(b)<<endl
#define pln3(a,b,c) cout<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define pln4(a,b,c,d) cout<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define ppln1(p,a) cout(p)<<(a)<<endl
#define ppln2(p,a,b) cout(p)<<(a)<<' '<<(b)<<endl
#define ppln3(p,a,b,c) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<endl
#define ppln4(p,a,b,c,d) cout(p)<<(a)<<' '<<(b)<<' '<<(c)<<' '<<(d)<<endl
#define debug(x) cerr<<#x<<" = "<<x<<endl

I arr[11];
bool rev[11];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    I n;cin>>n;
    ifor(i,1,n)
    {
        char op;I a;cin>>op>>a;
        I ps = 0;
        ifor(i,0,9)
        {
            I nxt = a&1;a>>=1;
            if(op=='|')
            {
                if(nxt==1){arr[ps] = 1;rev[ps] = 0;}
            }
            if(op=='&')
            {
                if(nxt==0){arr[ps] = 2;rev[ps] = 0;}
            }
            if(op=='^')
            {
                if(nxt==1)
                {
                    rev[ps]^=1;
                }
            }
            ++ps;
        }
    }
    I an = 0, xo = 0, o = 0;
    dfor(i,9,0)
    {
        an<<=1;xo<<=1;o<<=1;
        if(arr[i]!=2)an|=1;
        if(rev[i])xo|=1;
        if(arr[i]==1)o|=1;
    }
    I cnt = 0;
    if(an)++cnt;
    if(xo)++cnt;
    if(o)++cnt;
    cout << cnt << endl;
    if(an)cout << "& " << an << endl;
    if(o)cout << "| " << o << endl;
    if(xo)cout << "^ " << xo << endl;

    return 0;
}


//#include <bits/stdc++.h>
//*
#include <unordered_map>
#include <unordered_set>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <tuple>
#include <list>
#include <map>
#include <set>
//*/

#define ll long long int
#define var int
#define vi vector<var>
#define pii pair<var,var>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define all(X) (X).begin(),(X).end()
#define SZ 100010
const var INF = 0x3f3f3f3f; //3f3f3f3f;
using namespace std;

ostream &operator<<(ostream &os, const vi &v) { for(auto i: v) os<<' '<<i; return os; }
ostream &operator<<(ostream &os, const pii &p) { return os << " (" << p.fi << "," << p.se << ")"; }

int main(){
	cerr<<"go"<<endl;

	int n,x; scanf(" %d", &n);
	char s[11] = "++++++++++";
	char c;
	for(int k=0; k<n; k++){
		scanf(" %c %d", &c, &x);
		if(c=='|'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '1';
			}
		} else if(c=='&'){
			x = ~x;
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '0';
			}
		} else if(c=='^'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ){
					if(s[i]=='1') s[i] = '0';
					else if(s[i]=='0') s[i] = '1';
					else if(s[i]=='+') s[i] = '-';
					else if(s[i]=='-') s[i] = '+';
				}
			}
		}
	}

	int res[2] = {0,0};
	for(int i=0; i<10; i++){
		if(s[i] == '1' || s[i] == '0') res[0] |= (1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '0' || s[i] == '-') res[1] |= (1<<i);
	}

	cout<<2<<endl;
	cout<<"| "<<res[0]<<endl;
	cout<<"^ "<<res[1]<<endl;

	return 0;
}


//#include <bits/stdc++.h>
//*
#include <unordered_map>
#include <unordered_set>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <tuple>
#include <list>
#include <map>
#include <set>
//*/

#define ll long long int
#define var int
#define vi vector<var>
#define pii pair<var,var>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define all(X) (X).begin(),(X).end()
#define SZ 100010
const var INF = 0x3f3f3f3f; //3f3f3f3f;
using namespace std;

ostream &operator<<(ostream &os, const vi &v) { for(auto i: v) os<<' '<<i; return os; }
ostream &operator<<(ostream &os, const pii &p) { return os << " (" << p.fi << "," << p.se << ")"; }

int main(){
	cerr<<"go"<<endl;

	int n,x; scanf(" %d", &n);
	//cerr<<n<<endl;
	char s[11] = "++++++++++";
	char c;
	for(int k=0; k<n; k++){
		scanf(" %c %d", &c, &x);
		//cerr<<c<<x<<endl;
		if(c=='|'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '1';
			}
		} else if(c=='&'){
			for(int i=0; i<10; i++){
				if( ( x^(1<<i) )&(1<<i) ) s[i] = '0';
			}
		} else if(c=='^'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ){
					if(s[i]=='1') s[i] = '0';
					else if(s[i]=='0') s[i] = '1';
					else if(s[i]=='+') s[i] = '-';
					else if(s[i]=='-') s[i] = '+';
				}
			}
		}
	}
	//for(int i=0; i<10; i++) cout<<s[i]; cout<<endl;
	int res[3] = {0,1023,0};
	for(int i=0; i<10; i++){
		if(s[i] == '1') res[0] |= 1;
	}
	for(int i=0; i<10; i++){
		if(s[i] == '0') res[1] &= -1^(1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '-') res[2] ^= 1;
	}
	int cont=0;
	if(res[0]!=0) cont++;
	if(res[1]!=1023) cont++;
	if(res[2]!=0) cont++;

	cout<<cont<<endl;
	if(res[0]!=0) cout<<"| "<<res[0]<<endl;
	if(res[1]!=1023) cout<<"& "<<res[1]<<endl;
	if(res[2]!=0) cout<<"^ "<<res[2]<<endl;

	return 0;
}


//#include <bits/stdc++.h>
//*
#include <unordered_map>
#include <unordered_set>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <tuple>
#include <list>
#include <map>
#include <set>
//*/

#define ll long long int
#define var int
#define vi vector<var>
#define pii pair<var,var>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define all(X) (X).begin(),(X).end()
#define SZ 100010
const var INF = 0x3f3f3f3f; //3f3f3f3f;
using namespace std;

ostream &operator<<(ostream &os, const vi &v) { for(auto i: v) os<<' '<<i; return os; }
ostream &operator<<(ostream &os, const pii &p) { return os << " (" << p.fi << "," << p.se << ")"; }

int main(){
	cerr<<"go"<<endl;

	int n,x; scanf(" %d", &n);
	//cerr<<n<<endl;
	char s[11] = "++++++++++";
	char c;
	for(int k=0; k<n; k++){
		scanf(" %c %d", &c, &x);
		//cerr<<c<<x<<endl;
		if(c=='|'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '1';
			}
		} else if(c=='&'){
			x ^= (-1);
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '0';
				//if( ( x^(1<<i) )&(1<<i) ) s[i] = '0';
			}
		} else if(c=='^'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ){
					if(s[i]=='1') s[i] = '0';
					else if(s[i]=='0') s[i] = '1';
					else if(s[i]=='+') s[i] = '-';
					else if(s[i]=='-') s[i] = '+';
				}
			}
		}
	}
	//for(int i=0; i<10; i++) cout<<s[i]; cout<<endl;
	int res[3] = {0,1023,0};
	for(int i=0; i<10; i++){
		if(s[i] == '1') res[0] |= (1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '0') res[1] &= (-1)^(1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '-') res[2] ^= (1<<i);
	}
	int cont=0;
	if(res[0]!=0) cont++;
	if(res[1]!=1023) cont++;
	if(res[2]!=0) cont++;

	cout<<cont<<endl;
	if(res[0]!=0) cout<<"| "<<res[0]<<endl;
	if(res[1]!=1023) cout<<"& "<<res[1]<<endl;
	if(res[2]!=0) cout<<"^ "<<res[2]<<endl;

	return 0;
}


//#include <bits/stdc++.h>
//*
#include <unordered_map>
#include <unordered_set>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <tuple>
#include <list>
#include <map>
#include <set>
//*/

#define ll long long int
#define var int
#define vi vector<var>
#define pii pair<var,var>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define all(X) (X).begin(),(X).end()
#define SZ 100010
const var INF = 0x3f3f3f3f; //3f3f3f3f;
using namespace std;

ostream &operator<<(ostream &os, const vi &v) { for(auto i: v) os<<' '<<i; return os; }
ostream &operator<<(ostream &os, const pii &p) { return os << " (" << p.fi << "," << p.se << ")"; }

int main(){
	cerr<<"go"<<endl;

	int n,x; scanf(" %d", &n);
	//cerr<<n<<endl;
	char s[11] = "++++++++++";
	char c;
	for(int k=0; k<n; k++){
		scanf(" %c %d", &c, &x);
		//cerr<<c<<x<<endl;
		if(c=='|'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '1';
			}
		} else if(c=='&'){
			for(int i=0; i<10; i++){
				if( ( x^(1<<i) )&(1<<i) ) s[i] = '0';
			}
		} else if(c=='^'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ){
					if(s[i]=='1') s[i] = '0';
					else if(s[i]=='0') s[i] = '1';
					else if(s[i]=='+') s[i] = '-';
					else if(s[i]=='-') s[i] = '+';
				}
			}
		}
	}
	//for(int i=0; i<10; i++) cout<<s[i]; cout<<endl;
	int res[3] = {0,1023,0};
	for(int i=0; i<10; i++){
		if(s[i] == '1') res[0] |= 1;
	}
	for(int i=0; i<10; i++){
		if(s[i] == '0') res[1] &= -1^(1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '-') res[1] ^= 1;
	}
	int cont=0;
	if(res[0]!=0) cont++;
	if(res[1]!=1023) cont++;
	if(res[2]!=0) cont++;

	cout<<cont<<endl;
	if(res[0]!=0) cout<<"| "<<res[0]<<endl;
	if(res[1]!=1023) cout<<"& "<<res[1]<<endl;
	if(res[2]!=0) cout<<"^ "<<res[2]<<endl;

	return 0;
}


//#include <bits/stdc++.h>
//*
#include <unordered_map>
#include <unordered_set>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <tuple>
#include <list>
#include <map>
#include <set>
//*/

#define ll long long int
#define var int
#define vi vector<var>
#define pii pair<var,var>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define all(X) (X).begin(),(X).end()
#define SZ 100010
const var INF = 0x3f3f3f3f; //3f3f3f3f;
using namespace std;

ostream &operator<<(ostream &os, const vi &v) { for(auto i: v) os<<' '<<i; return os; }
ostream &operator<<(ostream &os, const pii &p) { return os << " (" << p.fi << "," << p.se << ")"; }

int main(){
	cerr<<"go"<<endl;

	int n,x; scanf(" %d", &n);
	//cerr<<n<<endl;
	char s[11] = "++++++++++";
	char c;
	for(int k=0; k<n; k++){
		scanf(" %c %d", &c, &x);
		//cerr<<c<<x<<endl;
		if(c=='|'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ) s[i] = '1';
			}
		} else if(c=='&'){
			for(int i=0; i<10; i++){
				x ^= -1;
				if( x&(1<<i) ) s[i] = '0';
				//if( ( x^(1<<i) )&(1<<i) ) s[i] = '0';
			}
		} else if(c=='^'){
			for(int i=0; i<10; i++){
				if( x&(1<<i) ){
					if(s[i]=='1') s[i] = '0';
					else if(s[i]=='0') s[i] = '1';
					else if(s[i]=='+') s[i] = '-';
					else if(s[i]=='-') s[i] = '+';
				}
			}
		}
	}
	//for(int i=0; i<10; i++) cout<<s[i]; cout<<endl;
	int res[3] = {0,1023,0};
	for(int i=0; i<10; i++){
		if(s[i] == '1') res[0] |= (1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '0') res[1] &= -1^(1<<i);
	}
	for(int i=0; i<10; i++){
		if(s[i] == '-') res[2] ^= (1<<i);
	}
	int cont=0;
	if(res[0]!=0) cont++;
	if(res[1]!=1023) cont++;
	if(res[2]!=0) cont++;

	cout<<cont<<endl;
	if(res[0]!=0) cout<<"| "<<res[0]<<endl;
	if(res[1]!=1023) cout<<"& "<<res[1]<<endl;
	if(res[2]!=0) cout<<"^ "<<res[2]<<endl;

	return 0;
}


#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    char ops;
    int num;

    bool fa[10], tr[10], re;
    for(int i = 0; i < n; ++i){
        fa[i] = false;
        tr[i] = true;
    }

    for(int i = 0; i < n; ++i){
        cin >> ops >> num;
        for(int j = 0; j < 10; ++j){
            re =  (bool)(num%2);
            if(ops == '&'){
                fa[j] &= re;
                tr[j] &= re;
            }else if (ops == '^'){
                fa[j] ^= re;
                tr[j] ^= re;
            }else{
                fa[j] |= re;
                tr[j] |= re;
            }
            num /= 2;
        }
    }
   bool a = 0, b = 0;
   for (int i = 9; i >= 0; --i){
       a *= 2; b *= 2;
       a += !(fa[i] == tr[i]);
       b += fa[i];
   }

   cout << "2\n";
   cout << "& " << a << '\n';
   cout << "^ " << b << '\n';
}


#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    char ops;
    int num;

    bool fa[10], tr[10], re;
    for(int i = 0; i < n; ++i){
        fa[i] = false;
        tr[i] = true;
    }

    for(int i = 0; i < n; ++i){
        cin >> ops >> num;
        for(int j = 0; j < 10; ++j){
            re =  ((num%2 == 1)? true : false);
            if(ops == '&'){
                fa[j] &= re;
                tr[j] &= re;
            }else if (ops == '^'){
                fa[j] ^= re;
                tr[j] ^= re;
            }else{
                fa[j] |= re;
                tr[j] |= re;
            }
            num /= 2;
        }
    }
   int a = 0, b = 0;
   for (int i = 9; i >= 0; --i){
      a *= 2; b *= 2;
      a += ((fa[i] == tr[i]) ? 1 : 0);
      b += ((tr[i]) ? 0 : 1);
   }

   cout << "2\n";
   cout << "| " << a << '\n';
   cout << "^ " << b << '\n';
}


#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    char ops;
    int num;

    bool fa[10], tr[10], re;
    for(int i = 0; i < n; ++i){
        fa[i] = false;
        tr[i] = true;
    }

    for(int i = 0; i < n; ++i){
        cin >> ops >> num;
        for(int j = 0; j < 10; ++j){
            re =  ((num%2 == 1)? true : false);
            if(ops == '&'){
                fa[j] &= re;
                tr[j] &= re;
            }else if (ops == '^'){
                fa[j] ^= re;
                tr[j] ^= re;
            }else{
                fa[j] |= re;
                tr[j] |= re;
            }
            num /= 2;
        }
    }
   int a = 0, b = 0;
   for (int i = 9; i >= 0; --i){
       a *= 2; b *= 2;
       a += (!(fa[i] == tr[i])? 1: 0);
       b += (fa[i] ? 1 : 0);
   }

   cout << "2\n";
   cout << "& " << a << '\n';
   cout << "^ " << b << '\n';
}


#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    char ops;
    int num, tr = 1023, fa = 0, a, b;

    for(int i = 0; i < n; ++i){
        cin >> ops >> num;
        if(ops == '&'){
            fa &= num;
            tr &= num;
        }else if (ops == '^'){
            fa ^= num;
            tr ^= num;
        }else{
            fa |= num;
            tr |= num;
        }
    }

   a = ((fa ^ tr) ^ 1023) % 1024;
   b = (tr ^ 1023) % 1024 ;

   cout << "2\n";
   cout << "| " << a << '\n';
   cout << "^ " << b << '\n';
}


#include <iostream>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    char ops;
    int num;

    bool fa[10], tr[10], re;
    for(int i = 0; i < 10; ++i){
        fa[i] = false;
        tr[i] = true;
    }

    for(int i = 0; i < n; ++i){
        cin >> ops >> num;
        for(int j = 0; j < 10; ++j){
            re =  ((num%2 == 1)? true : false);
            if(ops == '&'){
                fa[j] &= re;
                tr[j] &= re;
            }else if (ops == '^'){
                fa[j] ^= re;
                tr[j] ^= re;
            }else{
                fa[j] |= re;
                tr[j] |= re;
            }
            num /= 2;
        }
    }
   int a = 0, b = 0;
   for (int i = 9; i >= 0; --i){
      a *= 2; b *= 2;
      a += ((fa[i] == tr[i]) ? 1 : 0);
      b += ((tr[i]) ? 0 : 1);
   }

   cout << "2\n";
   cout << "| " << a << '\n';
   cout << "^ " << b << '\n';
}