#include <bits/stdc++.h>
using namespace std;
bool bit(int x, int pos) { return ((x >> pos) & 1); }
int main() {
  int n, a = 0, b = 1023, t;
  char type;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> type >> t;
    if (type == '&') {
      a = (a & t);
      b = (b & t);
    }
    if (type == '|') {
      a = (a | t);
      b = (b | t);
    }
    if (type == '^') {
      a = (a ^ t);
      b = (b ^ t);
    }
  }
  int xr = 0, r = 0, an = 1023;
  for (int i = 0; i < 10; i++) {
    if (bit(a, i) && !bit(b, i)) {
      xr = (xr | (1 << i));
    }
    if (bit(a, i) && bit(b, i)) {
      r = (r | (1 << i));
    }
    if (!bit(a, i) && !bit(b, i)) {
      an = (an ^ (1 << i));
    }
  }
  cout << 3 << "\n";
  cout << "| " << r << "\n";
  cout << "^ " << xr << "\n";
  cout << "& " << an << "\n";
  return 0;
}
