#include <bits/stdc++.h>
using namespace std;
int change(int s, char op, int val) {
  switch (op) {
    case '&':
      return val == 0 ? 0 : s;
      break;
    case '|':
      return val == 1 ? 1 : s;
      break;
    case '^':
      return s ^ val;
      break;
  }
}
void solve() {
  int n;
  cin >> n;
  vector<int> r(10, 2);
  for (int i = 0; i < n; ++i) {
    char c;
    int v;
    cin >> c >> v;
    for (int j = 0; j < 10; ++j) {
      r[j] = change(r[j], c, v & 1);
      v >>= 1;
    }
  }
  cout << 2 << endl;
  int andOp = 0;
  for (int j = 0; j < 10; ++j) {
    if (r[j] < 2) {
      andOp |= 1 << j;
    }
  }
  andOp = (~andOp) & ((1 << 10) - 1);
  cout << "& " << andOp << endl;
  int xorOp = 0;
  for (int j = 0; j < 10; ++j) {
    if (r[j] & 1) {
      xorOp |= 1 << j;
    }
  }
  cout << "^ " << xorOp << endl;
}
int main() {
  srand(132456);
  solve();
  return 0;
}
