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>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")
using namespace std;
struct state {
  int tp;
};
state states[10];
void ander(int ind, int vl) {
  if (vl == 1)
    return;
  else
    states[ind].tp = 1;
}
void orer(int ind, int vl) {
  if (vl == 0)
    return;
  else
    states[ind].tp = 2;
}
void xorer(int ind, int vl) {
  if (vl == 0) return;
  if (states[ind].tp == 1)
    states[ind].tp = 2;
  else if (states[ind].tp == 2)
    states[ind].tp = 1;
  else
    states[ind].tp = 3;
}
int toxor[10], toor[10], toand[10];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
       i += 1 - 2 * ((0) > (10)))
    states[i].tp = 0;
  int n;
  cin >> n;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    char ch;
    int vl;
    cin >> ch >> vl;
    for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
         i += 1 - 2 * ((0) > (10))) {
      if (ch == '&') ander(i, (vl >> i) & 1);
      if (ch == '|') orer(i, (vl >> i) & 1);
      if (ch == '^') xorer(i, (vl >> i) & 1);
    }
  }
  for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
       i += 1 - 2 * ((0) > (10)))
    toand[i] = 1;
  for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
       i += 1 - 2 * ((0) > (10))) {
    if (states[i].tp == 2) toor[i] = 1;
    if (states[i].tp == 1) toand[i] = 0;
    if (states[i].tp == 3) toxor[i] = 1;
  }
  cout << 3 << '\n';
  long long val = 0;
  for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
       i += 1 - 2 * ((0) > (10)))
    if (toor[i]) val += 1 << i;
  cout << "| " << val << '\n';
  val = 0;
  for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
       i += 1 - 2 * ((0) > (10)))
    if (toand[i]) val += 1 << i;
  val = 0;
  cout << "& " << val << '\n';
  for (__typeof(10) i = (0) - ((0) > (10)); i != (10) - ((0) > (10));
       i += 1 - 2 * ((0) > (10)))
    if (toxor[i]) val += 1 << i;
  cout << "^ " << val << '\n';
  val = 0;
  return 0;
}
