#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  char t;
  cin >> n;
  int op1 = 1023;
  int op0 = 0;
  for (int i = 0; i < n; i++) {
    char choice;
    int num;
    cin >> choice >> num;
    if (choice == '|') {
      op1 |= num;
      op0 |= num;
    }
    if (choice == '&') {
      op1 &= num;
      op0 &= num;
    }
    if (choice == '^') {
      op1 ^= num;
      op0 ^= num;
    }
  }
  int xornum = ~op1;
  int ornum = ~(op1 ^ op0);
  xornum &= 1023;
  ornum &= 1023;
  cout << "2" << '\n';
  cout << "| " << ornum << '\n';
  cout << "^ " << xornum << '\n';
  return 0;
}
