#include <iostream>

using namespace std;

const int maxn = 5e5;

int n, x, a = 0, b = 1023, y[3];

char c;

int main()

{

cin >> n;

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

{

cin >> c >> x;

if (c == ‘&’)

{

a &= x;

b &= x;

}

else if (c == ‘|’)

{

a |= x;

b |= x;

}

else

{

a ^= x;

b ^= x;

}

}

for (int i = 0; i < 10; i++)

{

if ((a & (1 << i)) && (b & (1 << i)))

{

y[0] += 1 << i;

y[1] += 1 << i;

}

else if (a & (1 << i))

{

y[0] += 1 << i;

y[2] += 1 << i;

}

else if (b & (1 << i))

{

y[0] += 1 << i;

}

}

cout << 3 << “\n& ” << y[0] << “\n| ” << y[1] << “\n^ ” << y[2];

}