#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char c;
  int x, zero = 0, one = 1023;
  for (int i = 0; i < n; i++) {
    cin >> c >> x;
    if (c == '&') {
      zero = zero & x;
      one = one & x;
    }
    if (c == '|') {
      zero = zero | x;
      one = one | x;
    }
    if (c == '^') {
      zero = zero ^ x;
      one = one ^ x;
    }
  }
  int bitmask = 0, bitmask1 = 0;
  int it = 1;
  pair<int, int> matrix[2][2] = {{make_pair(1, 1), make_pair(0, 0)},
                                 {make_pair(0, 1), make_pair(1, 0)}};
  for (int i = 0; i < 10; i++) {
    bitmask = bitmask | (matrix[(zero & it) > 0][(one & it) > 0].first * it);
    bitmask1 = bitmask1 | (matrix[(zero & it) > 0][(one & it) > 0].second * it);
    it <<= 1;
  }
  cout << 2 << "\n| " << bitmask << "\n^ " << bitmask1;
}
