#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char op;
  int num;
  int t[15];
  for (int i = 1; i <= 10; ++i) t[i] = 2;
  for (int i = 0; i < n; ++i) {
    cin >> op >> num;
    for (int i = 1; i <= 10; ++i) {
      int rnum = num % 2;
      num /= 2;
      if (op == '|') {
        if (rnum == 1) t[i] = 1;
      }
      if (op == '&') {
        if (rnum == 0) t[i] = 0;
      }
      if (op == '^') {
        if (rnum == 1) {
          if (t[i] == 0)
            t[i] = 1;
          else if (t[i] == 1)
            t[i] = 0;
          else if (t[i] == 2)
            t[i] = 3;
          else if (t[i] == 3)
            t[i] = 2;
        }
      }
    }
  }
  int lAnd = 1023;
  int lOr = 0;
  int lXor = 0;
  int p2 = 1;
  for (int i = 1; i <= 10; ++i) {
    if (t[i] == 0) lAnd -= p2;
    if (t[i] == 1) lOr += p2;
    if (t[i] == 3) lXor += p2;
    p2 *= 2;
  }
  cout << 3 << "\n";
  cout << "& " << lAnd << "\n";
  cout << "| " << lOr << "\n";
  cout << "^ " << lXor << "\n";
}
