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 gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ind[4];
  ind[0] = 1;
  ind[1] = 1;
  ind[2] = 0;
  ind[3] = 0;
  int modi[4];
  modi[0] = 0;
  modi[1] = 1;
  modi[2] = 1;
  modi[3] = 1;
  int op[2][2];
  op[0][0] = 0;
  op[0][1] = 1;
  op[1][0] = 2;
  op[1][1] = 3;
  char com[n];
  int c[n];
  for (int i = 0; i < n; i++) {
    cin >> com[i] >> c[i];
  }
  int CC[] = {0, 0, 0, 0};
  for (int b = 0; b < 10; b++) {
    int r0 = 0 << b;
    int r1 = 1 << b;
    for (int i = 0; i < n; i++) {
      if (com[i] == '|') {
        r0 = r0 | c[i];
        r1 = r1 | c[i];
      } else if (com[i] == '^') {
        r0 = r0 ^ c[i];
        r1 = r1 ^ c[i];
      } else if (com[i] == '&') {
        r0 = r0 & c[i];
        r1 = r1 & c[i];
      }
    }
    r0 = r0 & (1 << b) ? 1 : 0;
    r1 = r1 & (1 << b) ? 1 : 0;
    int ope = op[r0][r1];
    for (int i = 0; i < 4; i++) {
      if (i == ope) {
        CC[i] += (modi[i] << b);
      } else {
        CC[i] += (ind[i] << b);
      }
    }
  }
  char oper[] = {'&', '&', '^', '|'};
  cout << 4 << endl;
  for (int i = 0; i < 4; i++) {
    cout << oper[i] << " " << CC[i] << endl;
  }
}
