#include <bits/stdc++.h>
using namespace std;
int n;
int state[10];
int main() {
  cin >> n;
  for (int i = 0; i < 10; i++) {
    state[i] = 2;
  }
  for (int i = 0; i < n; i++) {
    char op;
    int x;
    cin >> op >> x;
    if (op == '&') {
      for (int j = 0; j < 10; j++) {
        if (!(x & (1 << j))) {
          state[j] = -1;
        }
      }
    } else if (op == '|') {
      for (int j = 0; j < 10; j++) {
        if (x & (1 << j)) {
          state[j] = 1;
        }
      }
    } else {
      for (int j = 0; j < 10; j++) {
        if (x & (1 << j)) {
          state[j] = -state[j];
        }
      }
    }
  }
  int andmask = 0, ormask = 0, xormask = 0;
  for (int i = 0; i < 10; i++) {
    if (state[i] == 1) {
      ormask |= 1 << i;
    } else if (state[i] == -1) {
      andmask |= 1 << i;
    } else if (state[i] == -2) {
      xormask |= 1 << i;
    }
  }
  andmask ^= (1 << 10) - 1;
  cout << "3\n& " << andmask << "\n| " << ormask << "\n^ " << xormask << '\n';
}
