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;
bool res[15][2];
char commands[500005];
int num[500005];
int Xor, Or, And;
int main() {
  int n, i, j, st = 1, j2;
  bool b, b2, BB;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> commands[i] >> num[i];
  }
  for (i = 0; i <= 9; i++) {
    for (j2 = 0; j2 <= 1; j2++) {
      b = j2;
      for (j = 0; j < n; j++) {
        b2 = (num[j] >> i) & 1;
        if (commands[j] == '|') {
          b = b2 | b;
        } else {
          if (commands[j] == '&') {
            b = b2 & b;
          } else {
            b = b2 ^ b;
          }
        }
      }
      if (j2 == 0)
        BB = b;
      else {
        if (BB == 0 && b == 0) {
          Or += st;
          Xor += st;
        }
        if (BB == 1 && b == 0) {
          Xor += st;
        }
        if (BB == 1 && b == 1) {
          Or += st;
        }
      }
    }
    st *= 2;
  }
  cout << "2" << endl;
  cout << "| " << Or << endl;
  cout << "^ " << Xor << endl;
  return 0;
}
