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;
void draganov_style() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
}
const int NMAX = 5e5 + 4;
int n, vers[14];
int dg[NMAX];
char op[NMAX];
int func(int bit, int t) {
  int x = (t << bit);
  for (int i = 0; i < n; i++) {
    if (op[i] == '|') x |= dg[i];
    if (op[i] == '^') x ^= dg[i];
    if (op[i] == '&') x &= dg[i];
  }
  return ((x >> bit) & 1);
}
int AND = 1023, XOR = 0;
int AND2 = 1023, XOR2 = 0;
void andf(int bit) { AND &= (~(1 << bit)); }
void xrf(int bit) { XOR |= (1 << bit); }
void andf2(int bit) { AND2 &= (~(1 << bit)); }
void xrf2(int bit) { XOR2 |= (1 << bit); }
int main() {
  draganov_style();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> op[i] >> dg[i];
  }
  for (int i = 0; i < 10; i++) {
    int nulBt = func(i, 0);
    int oneBt = func(i, 1);
    vers[i] = ((nulBt << 1) | oneBt);
  }
  for (int i = 0; i < 10; i++) {
    if (vers[i] == 1) continue;
    if (vers[i] == 0) andf(i);
    if (vers[i] == 2) xrf(i);
    if (vers[i] == 3) andf2(i), xrf2(i);
  }
  cout << "4\n& " << AND << "\n^ " << XOR << "\n& " << AND2 << "\n^ " << XOR2;
  return 0;
}
