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;
int n, a = 1023, b = 0, x, aa[11], bb[11], op1, op2, op3;
char op, what[12];
int main() {
  cin >> n;
  while (n > 0) {
    cin >> op >> x;
    if (op == '&') {
      a = a & x;
      b = b & x;
    }
    if (op == '^') {
      a = a ^ x;
      b = b ^ x;
    }
    if (op == '|') {
      a = a | x;
      b = b | x;
    }
    n = n - 1;
  }
  for (int i = 0; i <= 9; i++) aa[i] = bb[i] = 0;
  int n1 = 0, n2 = 0;
  while (a) {
    aa[n1] = a % 2;
    a = a / 2;
    n1 = n1 + 1;
  }
  while (b) {
    bb[n2] = b % 2;
    b = b / 2;
    n2 = n2 + 1;
  }
  for (int i = 0; i <= 9; i++) {
    if (aa[i] == 0 and bb[i] == 0) what[i] = '&', op1 = 1;
    if (aa[i] == 1 and bb[i] == 1) what[i] = '|', op2 = 1;
    if (aa[i] == 1 and bb[i] == 0) what[i] = '0';
    if (aa[i] == 0 and bb[i] == 1) what[i] = '^', op3 = 1;
  }
  cout << op1 + op2 + op3 << "\n";
  if (op1 == 1) {
    x = 0;
    n = 1;
    for (int i = 0; i <= 9; i++) {
      if (what[i] != '&') x = x + n;
      n = n * 2;
    }
    cout << "& " << x << "\n";
  }
  if (op2 == 1) {
    x = 0;
    n = 1;
    for (int i = 0; i <= 9; i++) {
      if (what[i] == '|') x = x + n;
      n = n * 2;
    }
    cout << "| " << x << "\n";
  }
  if (op3 == 1) {
    x = 0;
    n = 1;
    for (int i = 0; i <= 9; i++) {
      if (what[i] == '^') x = x + n;
      n = n * 2;
    }
    cout << "^ " << x << "\n";
  }
  return 0;
}
