1
& 0
 1
^ 123
 10
^ 218
& 150
| 935
& 61
| 588
& 897
| 411
| 584
^ 800
| 704
 3
& 1
& 3
& 5
 1
| 123
 1
^ 0
 1
| 1023
 3
& 242
^ 506
^ 522
 10
^ 160
& 1021
& 510
^ 470
& 1022
& 251
& 760
& 1016
| 772
| 515
 1
& 1023
 1
| 0
 2
| 56
^ 875
 1
^ 1023
 2
| 999
^ 689
 3
^ 125
^ 377
& 1019
 1
& 123

3
& 0
| 0
^ 0
 3
& 1023
| 0
^ 123
 3
& 763
| 763
^ 0
 3
& 1
| 0
^ 0
 3
& 1023
| 123
^ 0
 3
& 1023
| 0
^ 0
 3
& 1023
| 1023
^ 0
 3
& 1010
| 768
^ 240
 2
| 775
^ 112
 3
& 1023
| 0
^ 0
 3
& 1023
| 0
^ 0
 3
& 983
| 16
^ 835
 3
& 1023
| 0
^ 1023
 3
& 350
| 326
^ 16
 3
& 1019
| 0
^ 256
 3
& 123
| 0
^ 0

#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const long double pi = acos(-1);
char C[500500];
int X[500500];
int op_and[20];
int op_xor[20];
int op_or[20];
int apply(int bit, int pos, char op, int x) {
  if (op == '&') {
    if (x & (1 << pos))
      return bit & 1;
    else
      return 0;
  } else if (op == '|') {
    if (x & (1 << pos))
      return 1;
    else
      return bit;
  } else if (op == '^') {
    if (x & (1 << pos))
      return bit ^ 1;
    else
      return bit;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(15);
  cout << fixed;
  cout.tie(0);
  cin.tie(0);
  int N;
  cin >> N;
  for (int(i) = 0; (i) < (N); (i)++) cin >> C[i] >> X[i];
  for (int(i) = 0; (i) < (20); (i)++) op_and[i] = -1;
  for (int(i) = 0; (i) < (20); (i)++) op_xor[i] = -1;
  for (int(i) = 0; (i) < (20); (i)++) op_or[i] = -1;
  for (int(j) = 0; (j) < (10); (j)++) {
    int bit0 = 0;
    for (int(i) = 0; (i) < (N); (i)++) {
      bit0 = apply(bit0, j, C[i], X[i]);
    }
    int bit1 = 1;
    for (int(i) = 0; (i) < (N); (i)++) {
      bit1 = apply(bit1, j, C[i], X[i]);
    }
    if (bit0 == 0 && bit1 == 0) op_and[j] = 0;
    if (bit0 == 0 && bit1 == 1) op_xor[j] = 0;
    if (bit0 == 1 && bit1 == 0) op_xor[j] = 1;
    if (bit0 == 1 && bit1 == 1) op_or[j] = 1;
  }
  int andnum = 0;
  int xornum = 0;
  int ornum = 0;
  for (int(j) = 0; (j) < (10); (j)++) {
    if (op_and[j] != 0) andnum += 1 << j;
    if (op_xor[j] == 1) xornum += 1 << j;
    if (op_or[j] == 1) ornum += 1 << j;
  }
  cout << 3 << endl;
  cout << "& " << andnum << endl;
  cout << "| " << ornum << endl;
  cout << "^ " << xornum << endl;
}
