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 y1, y2;
int f(int a, int b, int c, int a1, int b1, int c1) {
  for (int i = 0; i < 3; i++) {
    if (i == 0) a ^= b;
    if (i == 1) a |= b;
    if (i == 2) a &= b;
    if (i == 0) a1 ^= b1;
    if (i == 1) a1 |= b1;
    if (i == 2) a1 &= b1;
    for (int j = 0; j < 3; j++) {
      if (j == 0) a ^= c;
      if (j == 1) a |= c;
      if (j == 2) a &= c;
      if (j == 0) a1 ^= c1;
      if (j == 1) a1 |= c1;
      if (j == 2) a1 &= c1;
      if (a == y1 && a1 == y1) {
        cout << 2 << endl;
        if (i == 0) cout << '^';
        if (i == 1) cout << '|';
        if (i == 2) cout << '&';
        cout << ' ' << b;
        cout << endl;
        if (j == 0) cout << '^';
        if (j == 1) cout << '|';
        if (j == 2) cout << '&';
        cout << ' ' << c;
        return 1;
      }
    }
  }
}
int main() {
  int n, k;
  char c;
  cin >> n;
  y1 = 0;
  y2 = 1023;
  for (int i = 0; i < n; i++) {
    cin >> c;
    cin >> k;
    if (c == '^') {
      y1 ^= k;
      y2 ^= k;
    }
    if (c == '|') {
      y1 |= k;
      y2 |= k;
    }
    if (c == '&') {
      y1 &= k;
      y2 &= k;
    }
  }
  int l = 0;
  int y3 = 0, y4 = 1023;
  for (int i = 0; 1; i++) {
    for (int j = 1023; 1; j--) {
      if (f(y3, i, j, y4, i, j)) {
        l = 1;
        break;
      }
    }
    if (l) break;
  }
}
